Remove unnecessary marks, they bring little value

This commit is contained in:
Stefan Ceriu
2022-11-28 10:32:32 +02:00
committed by Stefan Ceriu
parent 198127c5d7
commit 9589c689c3
40 changed files with 0 additions and 274 deletions
@@ -32,14 +32,8 @@ import Foundation
@dynamicMemberLookup @dynamicMemberLookup
@MainActor @MainActor
class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject { class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject {
// MARK: - Properties
// MARK: Private
fileprivate let viewActions: PassthroughSubject<ViewAction, Never> fileprivate let viewActions: PassthroughSubject<ViewAction, Never>
// MARK: Public
/// Get-able/Observable `Published` property for the `ViewState` /// Get-able/Observable `Published` property for the `ViewState`
@Published fileprivate(set) var viewState: ViewState @Published fileprivate(set) var viewState: ViewState
@@ -49,15 +43,11 @@ class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject {
set { viewState.bindings[keyPath: keyPath] = newValue } set { viewState.bindings[keyPath: keyPath] = newValue }
} }
// MARK: Setup
init(initialViewState: ViewState) { init(initialViewState: ViewState) {
self.viewActions = PassthroughSubject() self.viewActions = PassthroughSubject()
self.viewState = initialViewState self.viewState = initialViewState
} }
// MARK: Public
/// Send a `ViewAction` to the `ViewModel` for processing. /// Send a `ViewAction` to the `ViewModel` for processing.
/// - Parameter viewAction: The `ViewAction` to send to the `ViewModel`. /// - Parameter viewAction: The `ViewAction` to send to the `ViewModel`.
func send(viewAction: ViewAction) { func send(viewAction: ViewAction) {
@@ -75,10 +65,6 @@ class ViewModelContext<ViewState: BindableState, ViewAction>: ObservableObject {
class StateStoreViewModel<State: BindableState, ViewAction> { class StateStoreViewModel<State: BindableState, ViewAction> {
typealias Context = ViewModelContext<State, ViewAction> typealias Context = ViewModelContext<State, ViewAction>
// MARK: - Properties
// MARK: Public
/// For storing subscription references. /// For storing subscription references.
/// ///
/// Left as public for `ViewModel` implementations convenience. /// Left as public for `ViewModel` implementations convenience.
@@ -92,8 +78,6 @@ class StateStoreViewModel<State: BindableState, ViewAction> {
set { context.viewState = newValue } set { context.viewState = newValue }
} }
// MARK: Setup
init(initialViewState: State) { init(initialViewState: State) {
context = Context(initialViewState: initialViewState) context = Context(initialViewState: initialViewState)
context.viewActions context.viewActions
@@ -20,18 +20,10 @@ import SwiftUI
typealias AnalyticsPromptViewModelType = StateStoreViewModel<AnalyticsPromptViewState, AnalyticsPromptViewAction> typealias AnalyticsPromptViewModelType = StateStoreViewModel<AnalyticsPromptViewState, AnalyticsPromptViewAction>
class AnalyticsPromptViewModel: AnalyticsPromptViewModelType, AnalyticsPromptViewModelProtocol { class AnalyticsPromptViewModel: AnalyticsPromptViewModelType, AnalyticsPromptViewModelProtocol {
// MARK: - Properties
// MARK: Private
private let termsURL: URL private let termsURL: URL
// MARK: Public
var callback: (@MainActor (AnalyticsPromptViewModelAction) -> Void)? var callback: (@MainActor (AnalyticsPromptViewModelAction) -> Void)?
// MARK: - Setup
/// Initialize a view model with the specified prompt type and app display name. /// Initialize a view model with the specified prompt type and app display name.
init(termsURL: URL) { init(termsURL: URL) {
self.termsURL = termsURL self.termsURL = termsURL
@@ -18,18 +18,10 @@ import SwiftUI
/// A prompt that asks the user whether they would like to enable Analytics or not. /// A prompt that asks the user whether they would like to enable Analytics or not.
struct AnalyticsPrompt: View { struct AnalyticsPrompt: View {
// MARK: - Properties
// MARK: Private
private let horizontalPadding: CGFloat = 16 private let horizontalPadding: CGFloat = 16
// MARK: Public
@ObservedObject var context: AnalyticsPromptViewModel.Context @ObservedObject var context: AnalyticsPromptViewModel.Context
// MARK: Views
var body: some View { var body: some View {
GeometryReader { geometry in GeometryReader { geometry in
ScrollView { ScrollView {
@@ -17,14 +17,8 @@
import SwiftUI import SwiftUI
struct AnalyticsPromptCheckmarkItem: View { struct AnalyticsPromptCheckmarkItem: View {
// MARK: - Properties
// MARK: Private
private let attributedString: AttributedString private let attributedString: AttributedString
// MARK: - Setup
init(attributedString: AttributedString) { init(attributedString: AttributedString) {
self.attributedString = attributedString self.attributedString = attributedString
} }
@@ -33,8 +27,6 @@ struct AnalyticsPromptCheckmarkItem: View {
attributedString = AttributedString(string) attributedString = AttributedString(string)
} }
// MARK: - Views
var body: some View { var body: some View {
Label { Text(attributedString) } icon: { Label { Text(attributedString) } icon: {
Image(uiImage: Asset.Images.analyticsCheckmark.image) Image(uiImage: Asset.Images.analyticsCheckmark.image)
@@ -16,8 +16,6 @@
import Foundation import Foundation
// MARK: View model
enum LoginViewModelAction: CustomStringConvertible { enum LoginViewModelAction: CustomStringConvertible {
/// The user would like to select another server. /// The user would like to select another server.
case selectServer case selectServer
@@ -47,8 +45,6 @@ enum LoginViewModelAction: CustomStringConvertible {
} }
} }
// MARK: View
struct LoginViewState: BindableState { struct LoginViewState: BindableState {
/// Data about the selected homeserver. /// Data about the selected homeserver.
var homeserver: LoginHomeserver var homeserver: LoginHomeserver
@@ -19,14 +19,8 @@ import SwiftUI
typealias LoginViewModelType = StateStoreViewModel<LoginViewState, LoginViewAction> typealias LoginViewModelType = StateStoreViewModel<LoginViewState, LoginViewAction>
class LoginViewModel: LoginViewModelType, LoginViewModelProtocol { class LoginViewModel: LoginViewModelType, LoginViewModelProtocol {
// MARK: - Properties
// MARK: Public
var callback: (@MainActor (LoginViewModelAction) -> Void)? var callback: (@MainActor (LoginViewModelAction) -> Void)?
// MARK: - Setup
init(homeserver: LoginHomeserver) { init(homeserver: LoginHomeserver) {
let bindings = LoginBindings() let bindings = LoginBindings()
let viewState = LoginViewState(homeserver: homeserver, bindings: bindings) let viewState = LoginViewState(homeserver: homeserver, bindings: bindings)
@@ -34,8 +28,6 @@ class LoginViewModel: LoginViewModelType, LoginViewModelProtocol {
super.init(initialViewState: viewState) super.init(initialViewState: viewState)
} }
// MARK: - Public
override func process(viewAction: LoginViewAction) async { override func process(viewAction: LoginViewAction) async {
switch viewAction { switch viewAction {
case .selectServer: case .selectServer:
@@ -17,17 +17,11 @@
import SwiftUI import SwiftUI
struct LoginScreen: View { struct LoginScreen: View {
// MARK: - Properties
// MARK: Private
/// The focus state of the username text field. /// The focus state of the username text field.
@FocusState private var isUsernameFocused: Bool @FocusState private var isUsernameFocused: Bool
/// The focus state of the password text field. /// The focus state of the password text field.
@FocusState private var isPasswordFocused: Bool @FocusState private var isPasswordFocused: Bool
// MARK: Public
@ObservedObject var context: LoginViewModel.Context @ObservedObject var context: LoginViewModel.Context
var body: some View { var body: some View {
@@ -16,8 +16,6 @@
import Foundation import Foundation
// MARK: View model
enum ServerSelectionViewModelAction { enum ServerSelectionViewModelAction {
/// The user would like to use the homeserver at the given address. /// The user would like to use the homeserver at the given address.
case confirm(homeserverAddress: String) case confirm(homeserverAddress: String)
@@ -25,8 +23,6 @@ enum ServerSelectionViewModelAction {
case dismiss case dismiss
} }
// MARK: View
struct ServerSelectionViewState: BindableState { struct ServerSelectionViewState: BindableState {
/// View state that can be bound to from SwiftUI. /// View state that can be bound to from SwiftUI.
var bindings: ServerSelectionBindings var bindings: ServerSelectionBindings
@@ -19,16 +19,8 @@ import SwiftUI
typealias ServerSelectionViewModelType = StateStoreViewModel<ServerSelectionViewState, ServerSelectionViewAction> typealias ServerSelectionViewModelType = StateStoreViewModel<ServerSelectionViewState, ServerSelectionViewAction>
class ServerSelectionViewModel: ServerSelectionViewModelType, ServerSelectionViewModelProtocol { class ServerSelectionViewModel: ServerSelectionViewModelType, ServerSelectionViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: (@MainActor (ServerSelectionViewModelAction) -> Void)? var callback: (@MainActor (ServerSelectionViewModelAction) -> Void)?
// MARK: - Setup
init(homeserverAddress: String, isModallyPresented: Bool) { init(homeserverAddress: String, isModallyPresented: Bool) {
let bindings = ServerSelectionBindings(homeserverAddress: homeserverAddress, let bindings = ServerSelectionBindings(homeserverAddress: homeserverAddress,
slidingSyncProxyAddress: ElementSettings.shared.slidingSyncProxyBaseURLString) slidingSyncProxyAddress: ElementSettings.shared.slidingSyncProxyBaseURLString)
@@ -37,8 +29,6 @@ class ServerSelectionViewModel: ServerSelectionViewModelType, ServerSelectionVie
isModallyPresented: isModallyPresented)) isModallyPresented: isModallyPresented))
} }
// MARK: - Public
override func process(viewAction: ServerSelectionViewAction) async { override func process(viewAction: ServerSelectionViewAction) async {
switch viewAction { switch viewAction {
case .confirm: case .confirm:
@@ -16,8 +16,6 @@
import SwiftUI import SwiftUI
// MARK: Data
struct SoftLogoutCredentials { struct SoftLogoutCredentials {
let userId: String let userId: String
let homeserverName: String let homeserverName: String
@@ -25,8 +23,6 @@ struct SoftLogoutCredentials {
let deviceId: String? let deviceId: String?
} }
// MARK: View model
enum SoftLogoutViewModelAction: CustomStringConvertible { enum SoftLogoutViewModelAction: CustomStringConvertible {
/// Login with password /// Login with password
case login(String) case login(String)
@@ -52,8 +48,6 @@ enum SoftLogoutViewModelAction: CustomStringConvertible {
} }
} }
// MARK: View
struct SoftLogoutViewState: BindableState { struct SoftLogoutViewState: BindableState {
/// Soft logout credentials /// Soft logout credentials
var credentials: SoftLogoutCredentials var credentials: SoftLogoutCredentials
@@ -19,16 +19,8 @@ import SwiftUI
typealias SoftLogoutViewModelType = StateStoreViewModel<SoftLogoutViewState, SoftLogoutViewAction> typealias SoftLogoutViewModelType = StateStoreViewModel<SoftLogoutViewState, SoftLogoutViewAction>
class SoftLogoutViewModel: SoftLogoutViewModelType, SoftLogoutViewModelProtocol { class SoftLogoutViewModel: SoftLogoutViewModelType, SoftLogoutViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: (@MainActor (SoftLogoutViewModelAction) -> Void)? var callback: (@MainActor (SoftLogoutViewModelAction) -> Void)?
// MARK: - Setup
init(credentials: SoftLogoutCredentials, init(credentials: SoftLogoutCredentials,
homeserver: LoginHomeserver, homeserver: LoginHomeserver,
keyBackupNeeded: Bool, keyBackupNeeded: Bool,
@@ -41,8 +33,6 @@ class SoftLogoutViewModel: SoftLogoutViewModelType, SoftLogoutViewModelProtocol
super.init(initialViewState: viewState) super.init(initialViewState: viewState)
} }
// MARK: - Public
override func process(viewAction: SoftLogoutViewAction) async { override func process(viewAction: SoftLogoutViewAction) async {
switch viewAction { switch viewAction {
case .login: case .login:
@@ -17,21 +17,13 @@
import SwiftUI import SwiftUI
struct SoftLogoutScreen: View { struct SoftLogoutScreen: View {
// MARK: - Properties
// MARK: Private
@State private var showingClearDataConfirmation = false @State private var showingClearDataConfirmation = false
/// The focus state of the password text field. /// The focus state of the password text field.
@FocusState private var isPasswordFocused: Bool @FocusState private var isPasswordFocused: Bool
// MARK: Public
@ObservedObject var context: SoftLogoutViewModel.Context @ObservedObject var context: SoftLogoutViewModel.Context
// MARK: Views
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack(spacing: 0) { VStack(spacing: 0) {
@@ -17,10 +17,6 @@
import Foundation import Foundation
import UIKit import UIKit
// MARK: - Coordinator
// MARK: View model
enum BugReportViewModelAction { enum BugReportViewModelAction {
case cancel case cancel
case submitStarted case submitStarted
@@ -28,8 +24,6 @@ enum BugReportViewModelAction {
case submitFailed(error: Error) case submitFailed(error: Error)
} }
// MARK: View
struct BugReportViewState: BindableState { struct BugReportViewState: BindableState {
var screenshot: UIImage? var screenshot: UIImage?
var bindings: BugReportViewStateBindings var bindings: BugReportViewStateBindings
@@ -17,20 +17,14 @@
import SwiftUI import SwiftUI
struct BugReportScreen: View { struct BugReportScreen: View {
// MARK: Private
@Environment(\.horizontalSizeClass) private var horizontalSizeClass @Environment(\.horizontalSizeClass) private var horizontalSizeClass
private var horizontalPadding: CGFloat { private var horizontalPadding: CGFloat {
horizontalSizeClass == .regular ? 50 : 16 horizontalSizeClass == .regular ? 50 : 16
} }
// MARK: Public
@ObservedObject var context: BugReportViewModel.Context @ObservedObject var context: BugReportViewModel.Context
// MARK: Views
var body: some View { var body: some View {
GeometryReader { geometry in GeometryReader { geometry in
VStack { VStack {
@@ -16,16 +16,10 @@
import Foundation import Foundation
// MARK: - Coordinator
// MARK: View model
enum FilePreviewViewModelAction { enum FilePreviewViewModelAction {
case cancel case cancel
} }
// MARK: View
struct FilePreviewViewState: BindableState { struct FilePreviewViewState: BindableState {
let fileURL: URL let fileURL: URL
let title: String? let title: String?
@@ -19,22 +19,12 @@ import SwiftUI
typealias FilePreviewViewModelType = StateStoreViewModel<FilePreviewViewState, FilePreviewViewAction> typealias FilePreviewViewModelType = StateStoreViewModel<FilePreviewViewState, FilePreviewViewAction>
class FilePreviewViewModel: FilePreviewViewModelType, FilePreviewViewModelProtocol { class FilePreviewViewModel: FilePreviewViewModelType, FilePreviewViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: ((FilePreviewViewModelAction) -> Void)? var callback: ((FilePreviewViewModelAction) -> Void)?
// MARK: - Setup
init(fileURL: URL, title: String? = nil) { init(fileURL: URL, title: String? = nil) {
super.init(initialViewState: FilePreviewViewState(fileURL: fileURL, title: title)) super.init(initialViewState: FilePreviewViewState(fileURL: fileURL, title: title))
} }
// MARK: - Public
override func process(viewAction: FilePreviewViewAction) async { override func process(viewAction: FilePreviewViewAction) async {
switch viewAction { switch viewAction {
case .cancel: case .cancel:
@@ -19,20 +19,14 @@ import SwiftUI
import UIKit import UIKit
struct FilePreviewScreen: View { struct FilePreviewScreen: View {
// MARK: Private
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
var counterColor: Color { var counterColor: Color {
colorScheme == .light ? .element.secondaryContent : .element.tertiaryContent colorScheme == .light ? .element.secondaryContent : .element.tertiaryContent
} }
// MARK: Public
@ObservedObject var context: FilePreviewViewModel.Context @ObservedObject var context: FilePreviewViewModel.Context
// MARK: Views
var body: some View { var body: some View {
PreviewController(fileURL: context.viewState.fileURL, title: context.viewState.title) PreviewController(fileURL: context.viewState.fileURL, title: context.viewState.title)
} }
@@ -16,16 +16,10 @@
import Foundation import Foundation
// MARK: - Coordinator
// MARK: View model
enum MediaPlayerViewModelAction { enum MediaPlayerViewModelAction {
case cancel case cancel
} }
// MARK: View
struct MediaPlayerViewState: BindableState { struct MediaPlayerViewState: BindableState {
let mediaURL: URL let mediaURL: URL
let autoplay: Bool let autoplay: Bool
@@ -19,23 +19,13 @@ import SwiftUI
typealias MediaPlayerViewModelType = StateStoreViewModel<MediaPlayerViewState, MediaPlayerViewAction> typealias MediaPlayerViewModelType = StateStoreViewModel<MediaPlayerViewState, MediaPlayerViewAction>
class MediaPlayerViewModel: MediaPlayerViewModelType, MediaPlayerViewModelProtocol { class MediaPlayerViewModel: MediaPlayerViewModelType, MediaPlayerViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: ((MediaPlayerViewModelAction) -> Void)? var callback: ((MediaPlayerViewModelAction) -> Void)?
// MARK: - Setup
init(mediaURL: URL, autoplay: Bool = true) { init(mediaURL: URL, autoplay: Bool = true) {
super.init(initialViewState: MediaPlayerViewState(mediaURL: mediaURL, super.init(initialViewState: MediaPlayerViewState(mediaURL: mediaURL,
autoplay: autoplay)) autoplay: autoplay))
} }
// MARK: - Public
override func process(viewAction: MediaPlayerViewAction) async { override func process(viewAction: MediaPlayerViewAction) async {
switch viewAction { switch viewAction {
case .cancel: case .cancel:
@@ -18,12 +18,8 @@ import AVKit
import SwiftUI import SwiftUI
struct MediaPlayerScreen: View { struct MediaPlayerScreen: View {
// MARK: Public
@ObservedObject var context: MediaPlayerViewModel.Context @ObservedObject var context: MediaPlayerViewModel.Context
// MARK: Views
var body: some View { var body: some View {
VideoPlayer(player: player()) VideoPlayer(player: player())
.ignoresSafeArea() .ignoresSafeArea()
@@ -29,14 +29,10 @@ struct OnboardingPageContent {
let image: ImageAsset let image: ImageAsset
} }
// MARK: View model
enum OnboardingViewModelAction { enum OnboardingViewModelAction {
case login case login
} }
// MARK: View
struct OnboardingViewState: BindableState { struct OnboardingViewState: BindableState {
/// The colours of the background gradient shown behind the 4 pages. /// The colours of the background gradient shown behind the 4 pages.
private let gradientColors = [ private let gradientColors = [
@@ -20,22 +20,12 @@ import SwiftUI
typealias OnboardingViewModelType = StateStoreViewModel<OnboardingViewState, OnboardingViewAction> typealias OnboardingViewModelType = StateStoreViewModel<OnboardingViewState, OnboardingViewAction>
class OnboardingViewModel: OnboardingViewModelType, OnboardingViewModelProtocol { class OnboardingViewModel: OnboardingViewModelType, OnboardingViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: ((OnboardingViewModelAction) -> Void)? var callback: ((OnboardingViewModelAction) -> Void)?
// MARK: - Setup
init() { init() {
super.init(initialViewState: OnboardingViewState()) super.init(initialViewState: OnboardingViewState())
} }
// MARK: - Public
override func process(viewAction: OnboardingViewAction) async { override func process(viewAction: OnboardingViewAction) async {
switch viewAction { switch viewAction {
case .login: case .login:
@@ -17,17 +17,11 @@
import SwiftUI import SwiftUI
struct OnboardingPageIndicator: View { struct OnboardingPageIndicator: View {
// MARK: - Properties
// MARK: Public
/// The number of pages that are shown. /// The number of pages that are shown.
let pageCount: Int let pageCount: Int
/// The index of the current page /// The index of the current page
let pageIndex: Int let pageIndex: Int
// MARK: - Setup
internal init(pageCount: Int, pageIndex: Int) { internal init(pageCount: Int, pageIndex: Int) {
self.pageCount = pageCount self.pageCount = pageCount
@@ -17,15 +17,9 @@
import SwiftUI import SwiftUI
struct OnboardingPageView: View { struct OnboardingPageView: View {
// MARK: - Properties
// MARK: Public
/// The content that this page should display. /// The content that this page should display.
let content: OnboardingPageContent let content: OnboardingPageContent
// MARK: - Views
var body: some View { var body: some View {
VStack { VStack {
Image(content.image.name) Image(content.image.name)
@@ -19,10 +19,6 @@ import SwiftUI
/// The screen shown at the beginning of the onboarding flow. /// The screen shown at the beginning of the onboarding flow.
struct OnboardingScreen: View { struct OnboardingScreen: View {
// MARK: - Properties
// MARK: Private
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@Environment(\.layoutDirection) private var layoutDirection @Environment(\.layoutDirection) private var layoutDirection
@@ -34,8 +30,6 @@ struct OnboardingScreen: View {
/// The amount of offset to apply when a drag gesture is in progress. /// The amount of offset to apply when a drag gesture is in progress.
@State private var dragOffset: CGFloat = .zero @State private var dragOffset: CGFloat = .zero
// MARK: Public
@ObservedObject var context: OnboardingViewModel.Context @ObservedObject var context: OnboardingViewModel.Context
var body: some View { var body: some View {
@@ -16,14 +16,10 @@
import Foundation import Foundation
// MARK: View model
enum SessionVerificationViewModelAction { enum SessionVerificationViewModelAction {
case finished case finished
} }
// MARK: View
struct SessionVerificationViewState: BindableState { struct SessionVerificationViewState: BindableState {
var verificationState: SessionVerificationStateMachine.State = .initial var verificationState: SessionVerificationStateMachine.State = .initial
@@ -19,20 +19,12 @@ import SwiftUI
typealias SessionVerificationViewModelType = StateStoreViewModel<SessionVerificationViewState, SessionVerificationViewAction> typealias SessionVerificationViewModelType = StateStoreViewModel<SessionVerificationViewState, SessionVerificationViewAction>
class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVerificationViewModelProtocol { class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVerificationViewModelProtocol {
// MARK: - Properties
// MARK: Private
private let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol private let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol
private var stateMachine: SessionVerificationStateMachine private var stateMachine: SessionVerificationStateMachine
// MARK: Public
var callback: ((SessionVerificationViewModelAction) -> Void)? var callback: ((SessionVerificationViewModelAction) -> Void)?
// MARK: - Setup
init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol, init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol,
initialState: SessionVerificationViewState = SessionVerificationViewState()) { initialState: SessionVerificationViewState = SessionVerificationViewState()) {
self.sessionVerificationControllerProxy = sessionVerificationControllerProxy self.sessionVerificationControllerProxy = sessionVerificationControllerProxy
@@ -67,8 +59,6 @@ class SessionVerificationViewModel: SessionVerificationViewModelType, SessionVer
.store(in: &cancellables) .store(in: &cancellables)
} }
// MARK: - Public
override func process(viewAction: SessionVerificationViewAction) async { override func process(viewAction: SessionVerificationViewAction) async {
switch viewAction { switch viewAction {
case .start: case .start:
@@ -19,8 +19,6 @@ import SwiftUI
struct SessionVerificationScreen: View { struct SessionVerificationScreen: View {
@ObservedObject var context: SessionVerificationViewModel.Context @ObservedObject var context: SessionVerificationViewModel.Context
// MARK: Views
var body: some View { var body: some View {
NavigationView { NavigationView {
ScrollView { ScrollView {
@@ -17,10 +17,6 @@
import Foundation import Foundation
import UIKit import UIKit
// MARK: - Coordinator
// MARK: View model
enum SettingsViewModelAction { enum SettingsViewModelAction {
case close case close
case toggleAnalytics case toggleAnalytics
@@ -29,8 +25,6 @@ enum SettingsViewModelAction {
case logout case logout
} }
// MARK: View
struct SettingsViewState: BindableState { struct SettingsViewState: BindableState {
var bindings: SettingsViewStateBindings var bindings: SettingsViewStateBindings
var userID: String var userID: String
@@ -19,18 +19,10 @@ import SwiftUI
typealias SettingsViewModelType = StateStoreViewModel<SettingsViewState, SettingsViewAction> typealias SettingsViewModelType = StateStoreViewModel<SettingsViewState, SettingsViewAction>
class SettingsViewModel: SettingsViewModelType, SettingsViewModelProtocol { class SettingsViewModel: SettingsViewModelType, SettingsViewModelProtocol {
// MARK: - Properties
// MARK: Private
private let userSession: UserSessionProtocol private let userSession: UserSessionProtocol
// MARK: Public
var callback: ((SettingsViewModelAction) -> Void)? var callback: ((SettingsViewModelAction) -> Void)?
// MARK: - Setup
init(withUserSession userSession: UserSessionProtocol) { init(withUserSession userSession: UserSessionProtocol) {
self.userSession = userSession self.userSession = userSession
let bindings = SettingsViewStateBindings() let bindings = SettingsViewStateBindings()
@@ -51,8 +43,6 @@ class SettingsViewModel: SettingsViewModelType, SettingsViewModelProtocol {
} }
} }
// MARK: - Public
override func process(viewAction: SettingsViewAction) async { override func process(viewAction: SettingsViewAction) async {
switch viewAction { switch viewAction {
case .close: case .close:
@@ -17,8 +17,6 @@
import SwiftUI import SwiftUI
struct SettingsScreen: View { struct SettingsScreen: View {
// MARK: Private
@State private var showingLogoutConfirmation = false @State private var showingLogoutConfirmation = false
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@ObservedObject private var settings = ElementSettings.shared @ObservedObject private var settings = ElementSettings.shared
@@ -27,12 +25,8 @@ struct SettingsScreen: View {
@ScaledMetric private var menuIconSize = 30.0 @ScaledMetric private var menuIconSize = 30.0
private let listRowInsets = EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16) private let listRowInsets = EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16)
// MARK: Public
@ObservedObject var context: SettingsViewModel.Context @ObservedObject var context: SettingsViewModel.Context
// MARK: Views
var body: some View { var body: some View {
Form { Form {
userSection userSection
@@ -16,16 +16,10 @@
import Foundation import Foundation
// MARK: - Coordinator
// MARK: View model
enum VideoPlayerViewModelAction { enum VideoPlayerViewModelAction {
case cancel case cancel
} }
// MARK: View
struct VideoPlayerViewState: BindableState { struct VideoPlayerViewState: BindableState {
var videoURL: URL var videoURL: URL
var autoplay: Bool var autoplay: Bool
@@ -19,23 +19,13 @@ import SwiftUI
typealias VideoPlayerViewModelType = StateStoreViewModel<VideoPlayerViewState, VideoPlayerViewAction> typealias VideoPlayerViewModelType = StateStoreViewModel<VideoPlayerViewState, VideoPlayerViewAction>
class VideoPlayerViewModel: VideoPlayerViewModelType, VideoPlayerViewModelProtocol { class VideoPlayerViewModel: VideoPlayerViewModelType, VideoPlayerViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: ((VideoPlayerViewModelAction) -> Void)? var callback: ((VideoPlayerViewModelAction) -> Void)?
// MARK: - Setup
init(videoURL: URL, autoplay: Bool = true) { init(videoURL: URL, autoplay: Bool = true) {
super.init(initialViewState: VideoPlayerViewState(videoURL: videoURL, super.init(initialViewState: VideoPlayerViewState(videoURL: videoURL,
autoplay: autoplay)) autoplay: autoplay))
} }
// MARK: - Public
override func process(viewAction: VideoPlayerViewAction) async { override func process(viewAction: VideoPlayerViewAction) async {
switch viewAction { switch viewAction {
case .cancel: case .cancel:
@@ -18,12 +18,8 @@ import AVKit
import SwiftUI import SwiftUI
struct VideoPlayerScreen: View { struct VideoPlayerScreen: View {
// MARK: Public
@ObservedObject var context: VideoPlayerViewModel.Context @ObservedObject var context: VideoPlayerViewModel.Context
// MARK: Views
var body: some View { var body: some View {
VideoPlayer(player: player()) VideoPlayer(player: player())
.ignoresSafeArea() .ignoresSafeArea()
@@ -31,8 +31,6 @@ import PostHog
/// into `main`, update the AnalyticsEvents Swift package in `project.yml`. /// into `main`, update the AnalyticsEvents Swift package in `project.yml`.
/// ///
class Analytics { class Analytics {
// MARK: - Properties
/// The singleton instance to be used within the Riot target. /// The singleton instance to be used within the Riot target.
static let shared = Analytics() static let shared = Analytics()
@@ -54,8 +52,6 @@ class Analytics {
!ElementSettings.shared.hasSeenAnalyticsPrompt && BuildSettings.analyticsConfiguration.isEnabled !ElementSettings.shared.hasSeenAnalyticsPrompt && BuildSettings.analyticsConfiguration.isEnabled
} }
// MARK: - Public
/// Opts in to analytics tracking with the supplied user session. /// Opts in to analytics tracking with the supplied user session.
/// - Parameter userSession: The user session to use to when reading/generating the analytics ID. /// - Parameter userSession: The user session to use to when reading/generating the analytics ID.
/// The session will be ignored if not running. /// The session will be ignored if not running.
@@ -19,19 +19,11 @@ import Foundation
import MatrixRustSDK import MatrixRustSDK
class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol { class AuthenticationServiceProxy: AuthenticationServiceProxyProtocol {
// MARK: - Properties
// MARK: Private
private let authenticationService: AuthenticationService private let authenticationService: AuthenticationService
private let userSessionStore: UserSessionStoreProtocol private let userSessionStore: UserSessionStoreProtocol
// MARK: Public
private(set) var homeserver = LoginHomeserver(address: BuildSettings.defaultHomeserverAddress, loginMode: .unknown) private(set) var homeserver = LoginHomeserver(address: BuildSettings.defaultHomeserverAddress, loginMode: .unknown)
// MARK: - Setup
init(userSessionStore: UserSessionStoreProtocol) { init(userSessionStore: UserSessionStoreProtocol) {
self.userSessionStore = userSessionStore self.userSessionStore = userSessionStore
authenticationService = AuthenticationService(basePath: userSessionStore.baseDirectory.path) authenticationService = AuthenticationService(basePath: userSessionStore.baseDirectory.path)
@@ -37,8 +37,6 @@ final class TemplateCoordinator: CoordinatorProtocol {
viewModel = TemplateViewModel(promptType: parameters.promptType) viewModel = TemplateViewModel(promptType: parameters.promptType)
} }
// MARK: - Public
func start() { func start() {
viewModel.callback = { [weak self] action in viewModel.callback = { [weak self] action in
guard let self else { return } guard let self else { return }
@@ -16,8 +16,6 @@
import Foundation import Foundation
// MARK: - Coordinator
enum TemplatePromptType { enum TemplatePromptType {
case regular case regular
case upgrade case upgrade
@@ -45,15 +43,11 @@ extension TemplatePromptType: Identifiable, CaseIterable {
} }
} }
// MARK: View model
enum TemplateViewModelAction { enum TemplateViewModelAction {
case accept case accept
case cancel case cancel
} }
// MARK: View
struct TemplateViewState: BindableState { struct TemplateViewState: BindableState {
var promptType: TemplatePromptType var promptType: TemplatePromptType
var count: Int var count: Int
@@ -19,16 +19,8 @@ import SwiftUI
typealias TemplateViewModelType = StateStoreViewModel<TemplateViewState, TemplateViewAction> typealias TemplateViewModelType = StateStoreViewModel<TemplateViewState, TemplateViewAction>
class TemplateViewModel: TemplateViewModelType, TemplateViewModelProtocol { class TemplateViewModel: TemplateViewModelType, TemplateViewModelProtocol {
// MARK: - Properties
// MARK: Private
// MARK: Public
var callback: ((TemplateViewModelAction) -> Void)? var callback: ((TemplateViewModelAction) -> Void)?
// MARK: - Setup
init(promptType: TemplatePromptType, initialCount: Int = 0) { init(promptType: TemplatePromptType, initialCount: Int = 0) {
super.init(initialViewState: TemplateViewState(promptType: promptType, count: 0)) super.init(initialViewState: TemplateViewState(promptType: promptType, count: 0))
} }
@@ -17,20 +17,14 @@
import SwiftUI import SwiftUI
struct TemplateScreen: View { struct TemplateScreen: View {
// MARK: Private
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
var counterColor: Color { var counterColor: Color {
colorScheme == .light ? .element.secondaryContent : .element.tertiaryContent colorScheme == .light ? .element.secondaryContent : .element.tertiaryContent
} }
// MARK: Public
@ObservedObject var context: TemplateViewModel.Context @ObservedObject var context: TemplateViewModel.Context
// MARK: Views
var body: some View { var body: some View {
ScrollView { ScrollView {
mainContent mainContent