generated from element-hq/.github
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
21856e9
commit 761d508
Showing
18 changed files
with
309 additions
and
75 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ntX/Sources/Screens/Settings/AvancedOptionsScreen/AdvancedSettingsScreenCoordinator.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
enum AdvancedSettingsScreenCoordinatorAction { | ||
case clearCache | ||
} | ||
|
||
final class AdvancedSettingsScreenCoordinator: CoordinatorProtocol { | ||
private var viewModel: AdvancedSettingsScreenViewModelProtocol | ||
|
||
var callback: ((AdvancedSettingsScreenCoordinatorAction) -> Void)? | ||
|
||
init() { | ||
viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings) | ||
} | ||
|
||
func toPresentable() -> AnyView { | ||
AnyView(AdvancedSettingsScreen(context: viewModel.context)) | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
ElementX/Sources/Screens/Settings/AvancedOptionsScreen/AdvancedSettingsScreenModels.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
enum AdvancedSettingsScreenViewModelAction { } | ||
|
||
struct AdvancedSettingsScreenViewState: BindableState { | ||
var bindings: AdvancedSettingsScreenViewStateBindings | ||
} | ||
|
||
@dynamicMemberLookup | ||
struct AdvancedSettingsScreenViewStateBindings { | ||
private let advancedSettings: AdvancedSettingsProtocol | ||
|
||
init(advancedSettings: AdvancedSettingsProtocol) { | ||
self.advancedSettings = advancedSettings | ||
} | ||
|
||
subscript<Setting>(dynamicMember keyPath: ReferenceWritableKeyPath<AdvancedSettingsProtocol, Setting>) -> Setting { | ||
get { advancedSettings[keyPath: keyPath] } | ||
set { advancedSettings[keyPath: keyPath] = newValue } | ||
} | ||
} | ||
|
||
enum AdvancedSettingsScreenViewAction { } | ||
|
||
protocol AdvancedSettingsProtocol: AnyObject { | ||
var timelineStyle: TimelineStyle { get set } | ||
var viewSourceEnabled: Bool { get set } | ||
var richTextEditorEnabled: Bool { get set } | ||
} | ||
|
||
extension AppSettings: AdvancedSettingsProtocol { } |
32 changes: 32 additions & 0 deletions
32
ElementX/Sources/Screens/Settings/AvancedOptionsScreen/AdvancedSettingsScreenViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import SwiftUI | ||
|
||
typealias AdvancedSettingsScreenViewModelType = StateStoreViewModel<AdvancedSettingsScreenViewState, AdvancedSettingsScreenViewAction> | ||
|
||
class AdvancedSettingsScreenViewModel: AdvancedSettingsScreenViewModelType, AdvancedSettingsScreenViewModelProtocol { | ||
var callback: ((AdvancedSettingsScreenViewModelAction) -> Void)? | ||
|
||
init(advancedSettings: AdvancedSettingsProtocol) { | ||
let bindings = AdvancedSettingsScreenViewStateBindings(advancedSettings: advancedSettings) | ||
let state = AdvancedSettingsScreenViewState(bindings: bindings) | ||
|
||
super.init(initialViewState: state) | ||
} | ||
|
||
override func process(viewAction: AdvancedSettingsScreenViewAction) { } | ||
} |
23 changes: 23 additions & 0 deletions
23
...urces/Screens/Settings/AvancedOptionsScreen/AdvancedSettingsScreenViewModelProtocol.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
@MainActor | ||
protocol AdvancedSettingsScreenViewModelProtocol { | ||
var callback: ((AdvancedSettingsScreenViewModelAction) -> Void)? { get set } | ||
var context: AdvancedSettingsScreenViewModelType.Context { get } | ||
} |
65 changes: 65 additions & 0 deletions
65
ElementX/Sources/Screens/Settings/AvancedOptionsScreen/View/AdvancedSettingsScreen.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// Copyright 2022 New Vector Ltd | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Compound | ||
import SwiftUI | ||
|
||
struct AdvancedSettingsScreen: View { | ||
@ObservedObject var context: AdvancedSettingsScreenViewModel.Context | ||
@State private var showConfetti = false | ||
|
||
var body: some View { | ||
Form { | ||
Section { | ||
ListRow(label: .default(title: L10n.commonMessageLayout, | ||
systemIcon: .rectangleGrid1x2), | ||
kind: .picker(selection: $context.timelineStyle, | ||
items: TimelineStyle.allCases.map { (title: $0.name, tag: $0) })) | ||
|
||
ListRow(label: .default(title: L10n.actionViewSource, systemIcon: .mailAndTextMagnifyingglass), | ||
kind: .toggle($context.viewSourceEnabled)) | ||
|
||
ListRow(label: .default(title: L10n.commonRichTextEditor, icon: Image(asset: Asset.Images.textFormat)), | ||
kind: .toggle($context.richTextEditorEnabled)) | ||
} | ||
} | ||
.compoundList() | ||
.navigationTitle(L10n.commonAdvancedSettings) | ||
.navigationBarTitleDisplayMode(.inline) | ||
} | ||
} | ||
|
||
private extension TimelineStyle { | ||
var name: String { | ||
switch self { | ||
case .plain: | ||
return L10n.commonModern | ||
case .bubbles: | ||
return L10n.commonBubbles | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Previews | ||
|
||
struct AdvancedSettingsScreen_Previews: PreviewProvider { | ||
static let viewModel = AdvancedSettingsScreenViewModel(advancedSettings: ServiceLocator.shared.settings) | ||
static var previews: some View { | ||
NavigationStack { | ||
AdvancedSettingsScreen(context: viewModel.context) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.