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