mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 17:42:45 +02:00
Make naming of symbols consistent
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ final class TemplateUserProfileCoordinator: Coordinator {
|
||||
@available(iOS 14.0, *)
|
||||
init(session: MXSession) {
|
||||
self.session = session
|
||||
let viewModel = TemplateUserProfileViewModel(userService: MXTemplateUserService(session: session))
|
||||
let viewModel = TemplateUserProfileViewModel(userService: MXTemplateUserProfileService(session: session))
|
||||
let view = TemplateUserProfile(viewModel: viewModel)
|
||||
.addDependency(MXAvatarService.instantiate(mediaManager: session.mediaManager))
|
||||
templateUserProfileViewModel = viewModel
|
||||
|
||||
+4
-4
@@ -16,13 +16,13 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum TemplatePresence {
|
||||
enum TemplateUserProfilePresence {
|
||||
case online
|
||||
case idle
|
||||
case offline
|
||||
}
|
||||
|
||||
extension TemplatePresence {
|
||||
extension TemplateUserProfilePresence {
|
||||
var title: String {
|
||||
switch self {
|
||||
case .online:
|
||||
@@ -35,8 +35,8 @@ extension TemplatePresence {
|
||||
}
|
||||
}
|
||||
|
||||
extension TemplatePresence: CaseIterable { }
|
||||
extension TemplateUserProfilePresence: CaseIterable { }
|
||||
|
||||
extension TemplatePresence: Identifiable {
|
||||
extension TemplateUserProfilePresence: Identifiable {
|
||||
var id: Self { self }
|
||||
}
|
||||
+2
-2
@@ -16,6 +16,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum TemplateProfileStateAction {
|
||||
case updatePresence(TemplatePresence)
|
||||
enum TemplateUserProfileStateAction {
|
||||
case updatePresence(TemplateUserProfilePresence)
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum TemplateProfileViewAction {
|
||||
enum TemplateUserProfileViewAction {
|
||||
case cancel
|
||||
case done
|
||||
}
|
||||
+1
-1
@@ -19,5 +19,5 @@ import Foundation
|
||||
struct TemplateUserProfileViewState {
|
||||
let avatar: AvatarInputType?
|
||||
let displayName: String?
|
||||
var presence: TemplatePresence = .offline
|
||||
var presence: TemplateUserProfilePresence = .offline
|
||||
}
|
||||
|
||||
+5
-5
@@ -18,7 +18,7 @@ import Foundation
|
||||
import Combine
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
class MXTemplateUserService: TemplateUserServiceProtocol {
|
||||
class MXTemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
@@ -26,7 +26,7 @@ class MXTemplateUserService: TemplateUserServiceProtocol {
|
||||
|
||||
private let session: MXSession
|
||||
private var listenerReference: Any!
|
||||
@Published private var presence: TemplatePresence = .offline
|
||||
@Published private var presence: TemplateUserProfilePresence = .offline
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@@ -42,7 +42,7 @@ class MXTemplateUserService: TemplateUserServiceProtocol {
|
||||
session.myUser.avatarUrl
|
||||
}
|
||||
|
||||
var presencePublisher: AnyPublisher<TemplatePresence, Never> {
|
||||
var presencePublisher: AnyPublisher<TemplateUserProfilePresence, Never> {
|
||||
$presence.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ class MXTemplateUserService: TemplateUserServiceProtocol {
|
||||
let event = event,
|
||||
case .presence = MXEventType(identifier: event.eventId)
|
||||
else { return }
|
||||
self.presence = TemplatePresence(mxPresence: self.session.myUser.presence)
|
||||
self.presence = TemplateUserProfilePresence(mxPresence: self.session.myUser.presence)
|
||||
}
|
||||
self.listenerReference = listenerReference
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class MXTemplateUserService: TemplateUserServiceProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension TemplatePresence {
|
||||
fileprivate extension TemplateUserProfilePresence {
|
||||
|
||||
init(mxPresence: MXPresence) {
|
||||
switch mxPresence {
|
||||
+4
-4
@@ -18,11 +18,11 @@ import Foundation
|
||||
import Combine
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
class MockTemplateUserService: TemplateUserServiceProtocol {
|
||||
class MockTemplateUserProfileService: TemplateUserProfileServiceProtocol {
|
||||
|
||||
static let example = MockTemplateUserService()
|
||||
@Published var presence: TemplatePresence = .online
|
||||
var presencePublisher: AnyPublisher<TemplatePresence, Never> {
|
||||
static let example = MockTemplateUserProfileService()
|
||||
@Published var presence: TemplateUserProfilePresence = .online
|
||||
var presencePublisher: AnyPublisher<TemplateUserProfilePresence, Never> {
|
||||
$presence.eraseToAnyPublisher()
|
||||
}
|
||||
let userId: String = "123"
|
||||
+3
-3
@@ -18,15 +18,15 @@ import Foundation
|
||||
import Combine
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
protocol TemplateUserServiceProtocol: Avatarable {
|
||||
protocol TemplateUserProfileServiceProtocol: Avatarable {
|
||||
var userId: String { get }
|
||||
var displayName: String? { get }
|
||||
var avatarUrl: String? { get }
|
||||
var presencePublisher: AnyPublisher<TemplatePresence, Never> { get }
|
||||
var presencePublisher: AnyPublisher<TemplateUserProfilePresence, Never> { get }
|
||||
}
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
extension TemplateUserServiceProtocol {
|
||||
extension TemplateUserProfileServiceProtocol {
|
||||
var mxContentUri: String? {
|
||||
avatarUrl
|
||||
}
|
||||
@@ -62,7 +62,7 @@ struct TemplateUserProfile: View {
|
||||
@available(iOS 14.0, *)
|
||||
struct TemplateUserProfile_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
TemplateUserProfile(viewModel: TemplateUserProfileViewModel(userService: MockTemplateUserService.example))
|
||||
TemplateUserProfile(viewModel: TemplateUserProfileViewModel(userService: MockTemplateUserProfileService.example))
|
||||
.addDependency(MockAvatarService.example)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ struct TemplateUserProfileHeader: View {
|
||||
@Environment(\.theme) var theme: ThemeSwiftUI
|
||||
let avatar: AvatarInputType?
|
||||
let displayName: String?
|
||||
let presence: TemplatePresence
|
||||
let presence: TemplateUserProfilePresence
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
@@ -37,7 +37,7 @@ struct TemplateUserProfileHeader: View {
|
||||
VStack(spacing: 8){
|
||||
Text(displayName ?? "")
|
||||
.font(theme.fonts.title3)
|
||||
TemplatePresenceView(presense: presence)
|
||||
TemplateUserProfilePresenceView(presense: presence)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -17,9 +17,9 @@
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS 14.0, *)
|
||||
struct TemplatePresenceView: View {
|
||||
struct TemplateUserProfilePresenceView: View {
|
||||
|
||||
let presense: TemplatePresence
|
||||
let presense: TemplateUserProfilePresence
|
||||
|
||||
var foregroundColor: Color {
|
||||
switch presense {
|
||||
@@ -51,8 +51,8 @@ struct TemplatePresenceView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack(alignment:.leading){
|
||||
Text("Presence")
|
||||
ForEach(TemplatePresence.allCases) { presence in
|
||||
TemplatePresenceView(presense: presence)
|
||||
ForEach(TemplateUserProfilePresence.allCases) { presence in
|
||||
TemplateUserProfilePresenceView(presense: presence)
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -23,7 +23,7 @@ class TemplateUserProfileViewModel: ObservableObject, TemplateUserProfileViewMod
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
private let userService: TemplateUserServiceProtocol
|
||||
private let userService: TemplateUserProfileServiceProtocol
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
// MARK: Public
|
||||
@@ -31,24 +31,24 @@ class TemplateUserProfileViewModel: ObservableObject, TemplateUserProfileViewMod
|
||||
|
||||
var completion: ((TemplateUserProfileViewModelResult) -> Void)?
|
||||
|
||||
private static func defaultState(userService: TemplateUserServiceProtocol) -> TemplateUserProfileViewState {
|
||||
private static func defaultState(userService: TemplateUserProfileServiceProtocol) -> TemplateUserProfileViewState {
|
||||
return TemplateUserProfileViewState(avatar: userService.avatarData, displayName: userService.displayName)
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
init(userService: TemplateUserServiceProtocol, initialState: TemplateUserProfileViewState? = nil) {
|
||||
init(userService: TemplateUserProfileServiceProtocol, initialState: TemplateUserProfileViewState? = nil) {
|
||||
self.userService = userService
|
||||
self.viewState = initialState ?? Self.defaultState(userService: userService)
|
||||
|
||||
userService.presencePublisher
|
||||
.map(TemplateProfileStateAction.updatePresence)
|
||||
.map(TemplateUserProfileStateAction.updatePresence)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(receiveValue: self.dispatch(action:))
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
// MARK: - Public methods
|
||||
func proccess(viewAction: TemplateProfileViewAction) {
|
||||
func proccess(viewAction: TemplateUserProfileViewAction) {
|
||||
switch viewAction {
|
||||
case .cancel:
|
||||
self.cancel()
|
||||
@@ -61,7 +61,7 @@ class TemplateUserProfileViewModel: ObservableObject, TemplateUserProfileViewMod
|
||||
/**
|
||||
Send state actions to mutate the state.
|
||||
*/
|
||||
private func dispatch(action: TemplateProfileStateAction) {
|
||||
private func dispatch(action: TemplateUserProfileStateAction) {
|
||||
var newState = self.viewState
|
||||
reducer(state: &newState, action: action)
|
||||
self.viewState = newState
|
||||
@@ -70,7 +70,7 @@ class TemplateUserProfileViewModel: ObservableObject, TemplateUserProfileViewMod
|
||||
/**
|
||||
A redux style reducer, all modifications to state happen here. Recieves a state and a state action and produces a new state.
|
||||
*/
|
||||
private func reducer(state: inout TemplateUserProfileViewState, action: TemplateProfileStateAction) {
|
||||
private func reducer(state: inout TemplateUserProfileViewState, action: TemplateUserProfileStateAction) {
|
||||
switch action {
|
||||
case .updatePresence(let presence):
|
||||
state.presence = presence
|
||||
|
||||
Reference in New Issue
Block a user