mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
@@ -14,6 +14,7 @@
|
|||||||
"settings_appearance" = "Appearance";
|
"settings_appearance" = "Appearance";
|
||||||
"settings_timeline_style" = "Message layout";
|
"settings_timeline_style" = "Message layout";
|
||||||
"settings_session_verification" = "Complete verification";
|
"settings_session_verification" = "Complete verification";
|
||||||
|
"settings_developer_options" = "Developer options";
|
||||||
|
|
||||||
"room_timeline_style_plain_long_description" = "Modern";
|
"room_timeline_style_plain_long_description" = "Modern";
|
||||||
"room_timeline_style_bubbled_long_description" = "Bubbles";
|
"room_timeline_style_bubbled_long_description" = "Bubbles";
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ final class AppSettings: ObservableObject {
|
|||||||
|
|
||||||
// MARK: - Application
|
// MARK: - Application
|
||||||
|
|
||||||
|
lazy var canShowDeveloperOptions: Bool = {
|
||||||
|
#if DEBUG
|
||||||
|
true
|
||||||
|
#else
|
||||||
|
let apps = ["io.element.elementx.nightly", "io.element.elementx.pr"]
|
||||||
|
return apps.contains(InfoPlistReader.main.baseBundleIdentifier)
|
||||||
|
#endif
|
||||||
|
}()
|
||||||
|
|
||||||
/// The last known version of the app that was launched on this device, which is
|
/// The last known version of the app that was launched on this device, which is
|
||||||
/// used to detect when migrations should be run. When `nil` the app may have been
|
/// used to detect when migrations should be run. When `nil` the app may have been
|
||||||
/// deleted between runs so should clear data in the shared container and keychain.
|
/// deleted between runs so should clear data in the shared container and keychain.
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ extension ElementL10n {
|
|||||||
public static let sessionVerificationStart = ElementL10n.tr("Untranslated", "session_verification_start")
|
public static let sessionVerificationStart = ElementL10n.tr("Untranslated", "session_verification_start")
|
||||||
/// Appearance
|
/// Appearance
|
||||||
public static let settingsAppearance = ElementL10n.tr("Untranslated", "settings_appearance")
|
public static let settingsAppearance = ElementL10n.tr("Untranslated", "settings_appearance")
|
||||||
|
/// Developer options
|
||||||
|
public static let settingsDeveloperOptions = ElementL10n.tr("Untranslated", "settings_developer_options")
|
||||||
/// Complete verification
|
/// Complete verification
|
||||||
public static let settingsSessionVerification = ElementL10n.tr("Untranslated", "settings_session_verification")
|
public static let settingsSessionVerification = ElementL10n.tr("Untranslated", "settings_session_verification")
|
||||||
/// Message layout
|
/// Message layout
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,74 @@
|
|||||||
|
//
|
||||||
|
// 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 SceneKit
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
class EffectsScene: SCNScene {
|
||||||
|
private enum Constants {
|
||||||
|
static let confettiSceneName = "ConfettiScene.scn"
|
||||||
|
static let particlesNodeName = "particles"
|
||||||
|
}
|
||||||
|
|
||||||
|
static func confetti() -> EffectsScene? {
|
||||||
|
guard let scene = EffectsScene(named: Constants.confettiSceneName) else { return nil }
|
||||||
|
|
||||||
|
let colors: [[Float]] = Color.element.contentAndAvatars.compactMap(\.floatComponents)
|
||||||
|
|
||||||
|
if let particles = scene.rootNode.childNode(withName: Constants.particlesNodeName, recursively: false)?.particleSystems?.first {
|
||||||
|
// The particles need a non-zero color variation for the handler to affect the color
|
||||||
|
particles.particleColorVariation = SCNVector4(x: 0, y: 0, z: 0, w: 0.1)
|
||||||
|
|
||||||
|
// Add a handler to customize the color of the particles.
|
||||||
|
particles.handle(.birth, forProperties: [.color]) { data, dataStride, _, count in
|
||||||
|
for index in 0..<count {
|
||||||
|
// Pick a random color to apply to the particle.
|
||||||
|
guard let color = colors.randomElement() else { continue }
|
||||||
|
|
||||||
|
// Get the particle's color pointer.
|
||||||
|
let colorPointer = data[0] + dataStride[0] * index
|
||||||
|
let rgbaPointer = colorPointer.bindMemory(to: Float.self, capacity: dataStride[0])
|
||||||
|
|
||||||
|
// Update the color for the particle.
|
||||||
|
rgbaPointer[0] = color[0]
|
||||||
|
rgbaPointer[1] = color[1]
|
||||||
|
rgbaPointer[2] = color[2]
|
||||||
|
rgbaPointer[3] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return scene
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private extension Color {
|
||||||
|
/// The color's components as an array of floats in the extended linear sRGB colorspace.
|
||||||
|
///
|
||||||
|
/// SceneKit works in a colorspace with a linear gamma, which is why this conversion is necessary.
|
||||||
|
var floatComponents: [Float]? {
|
||||||
|
// Get the CGColor from a UIColor as it is nil on Color when loaded from an asset catalog.
|
||||||
|
let cgColor = UIColor(self).cgColor
|
||||||
|
|
||||||
|
guard
|
||||||
|
let colorSpace = CGColorSpace(name: CGColorSpace.extendedLinearSRGB),
|
||||||
|
let linearColor = cgColor.converted(to: colorSpace, intent: .defaultIntent, options: nil),
|
||||||
|
let components = linearColor.components
|
||||||
|
else { return nil }
|
||||||
|
|
||||||
|
return components.map { Float($0) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
//
|
||||||
|
// 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 SceneKit
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
/// A SwiftUI wrapper around `SCNView`, that unlike `SceneView` allows the
|
||||||
|
/// scene to have a transparent background and be rendered on top of other views.
|
||||||
|
struct EffectsView: UIViewRepresentable {
|
||||||
|
enum Effect {
|
||||||
|
/// A confetti drop effect from the top centre of the screen.
|
||||||
|
case confetti
|
||||||
|
/// No effect will be shown.
|
||||||
|
case none
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The type of effects to be shown in the view.
|
||||||
|
var effect: Effect
|
||||||
|
|
||||||
|
func makeUIView(context: Context) -> SCNView {
|
||||||
|
SCNView(frame: .zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateUIView(_ sceneView: SCNView, context: Context) {
|
||||||
|
sceneView.scene = makeScene()
|
||||||
|
sceneView.backgroundColor = .clear
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Private
|
||||||
|
|
||||||
|
private func makeScene() -> EffectsScene? {
|
||||||
|
switch effect {
|
||||||
|
case .confetti:
|
||||||
|
return EffectsScene.confetti()
|
||||||
|
case .none:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EffectsView_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
EffectsView(effect: .confetti)
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||||
|
private let viewModel: DeveloperOptionsScreenViewModelProtocol
|
||||||
|
|
||||||
|
init() {
|
||||||
|
viewModel = DeveloperOptionsScreenViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
func toPresentable() -> AnyView {
|
||||||
|
AnyView(DeveloperOptionsScreenScreen(context: viewModel.context))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// 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 DeveloperOptionsScreenViewModelAction { }
|
||||||
|
|
||||||
|
struct DeveloperOptionsScreenViewState: BindableState {
|
||||||
|
var bindings: DeveloperOptionsScreenViewStateBindings
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DeveloperOptionsScreenViewStateBindings { }
|
||||||
|
|
||||||
|
enum DeveloperOptionsScreenViewAction { }
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// 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 DeveloperOptionsScreenViewModelType = StateStoreViewModel<DeveloperOptionsScreenViewState, DeveloperOptionsScreenViewAction>
|
||||||
|
|
||||||
|
class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, DeveloperOptionsScreenViewModelProtocol {
|
||||||
|
var callback: ((DeveloperOptionsScreenViewModelAction) -> Void)?
|
||||||
|
|
||||||
|
init() {
|
||||||
|
super.init(initialViewState: DeveloperOptionsScreenViewState(bindings: DeveloperOptionsScreenViewStateBindings()))
|
||||||
|
}
|
||||||
|
}
|
||||||
+23
@@ -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 DeveloperOptionsScreenViewModelProtocol {
|
||||||
|
var callback: ((DeveloperOptionsScreenViewModelAction) -> Void)? { get set }
|
||||||
|
var context: DeveloperOptionsScreenViewModelType.Context { get }
|
||||||
|
}
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
struct DeveloperOptionsScreenScreen: View {
|
||||||
|
@ObservedObject var context: DeveloperOptionsScreenViewModel.Context
|
||||||
|
@State private var showConfetti = false
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Form {
|
||||||
|
Section {
|
||||||
|
Button {
|
||||||
|
showConfetti = true
|
||||||
|
} label: {
|
||||||
|
Text("🥳")
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.listRowBackground(Color.element.formRowBackground)
|
||||||
|
}
|
||||||
|
.overlay(effectsView)
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(Color.element.formBackground.ignoresSafeArea())
|
||||||
|
.navigationTitle(ElementL10n.settingsDeveloperOptions)
|
||||||
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var effectsView: some View {
|
||||||
|
if showConfetti {
|
||||||
|
EffectsView(effect: .confetti)
|
||||||
|
.task { await removeConfettiAfterDelay() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func removeConfettiAfterDelay() async {
|
||||||
|
try? await Task.sleep(for: .seconds(4))
|
||||||
|
showConfetti = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Previews
|
||||||
|
|
||||||
|
struct DeveloperOptionsScreen_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
let viewModel = DeveloperOptionsScreenViewModel()
|
||||||
|
DeveloperOptionsScreenScreen(context: viewModel.context)
|
||||||
|
.tint(.element.accent)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -88,7 +88,7 @@ struct RoomScreenViewStateBindings {
|
|||||||
/// Information describing the currently displayed alert.
|
/// Information describing the currently displayed alert.
|
||||||
var alertInfo: AlertInfo<RoomScreenErrorType>?
|
var alertInfo: AlertInfo<RoomScreenErrorType>?
|
||||||
|
|
||||||
var debugInfo: DebugScreen.DebugInfo?
|
var debugInfo: TimelineItemDebugView.DebugInfo?
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RoomScreenErrorType: Hashable {
|
enum RoomScreenErrorType: Hashable {
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
|||||||
actions.append(.redact)
|
actions.append(.redact)
|
||||||
}
|
}
|
||||||
|
|
||||||
var debugActions: [TimelineItemContextMenuAction] = [.viewSource]
|
var debugActions: [TimelineItemContextMenuAction] = ServiceLocator.shared.settings.canShowDeveloperOptions ? [.viewSource] : []
|
||||||
|
|
||||||
if let item = timelineItem as? EncryptedRoomTimelineItem,
|
if let item = timelineItem as? EncryptedRoomTimelineItem,
|
||||||
case let .megolmV1AesSha2(sessionID) = item.encryptionType {
|
case let .megolmV1AesSha2(sessionID) = item.encryptionType {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ struct RoomScreen: View {
|
|||||||
.toolbarBackground(.visible, for: .navigationBar) // Fix the toolbar's background.
|
.toolbarBackground(.visible, for: .navigationBar) // Fix the toolbar's background.
|
||||||
.overlay { loadingIndicator }
|
.overlay { loadingIndicator }
|
||||||
.alert(item: $context.alertInfo) { $0.alert }
|
.alert(item: $context.alertInfo) { $0.alert }
|
||||||
.sheet(item: $context.debugInfo) { DebugScreen(info: $0) }
|
.sheet(item: $context.debugInfo) { TimelineItemDebugView(info: $0) }
|
||||||
.task(id: context.viewState.roomId) {
|
.task(id: context.viewState.roomId) {
|
||||||
// Give a couple of seconds for items to load and to see them.
|
// Give a couple of seconds for items to load and to see them.
|
||||||
try? await Task.sleep(for: .seconds(2))
|
try? await Task.sleep(for: .seconds(2))
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct DebugScreen: View {
|
struct TimelineItemDebugView: View {
|
||||||
struct DebugInfo: Identifiable {
|
struct DebugInfo: Identifiable {
|
||||||
let id = UUID()
|
let id = UUID()
|
||||||
let title: String
|
let title: String
|
||||||
@@ -52,6 +52,8 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
|||||||
self.presentBugReportScreen()
|
self.presentBugReportScreen()
|
||||||
case .sessionVerification:
|
case .sessionVerification:
|
||||||
self.verifySession()
|
self.verifySession()
|
||||||
|
case .developerOptions:
|
||||||
|
self.presentDeveloperOptions()
|
||||||
case .logout:
|
case .logout:
|
||||||
self.callback?(.logout)
|
self.callback?(.logout)
|
||||||
}
|
}
|
||||||
@@ -110,6 +112,11 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
|||||||
self?.parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
|
self?.parameters.navigationStackCoordinator?.setSheetCoordinator(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func presentDeveloperOptions() {
|
||||||
|
let coordinator = DeveloperOptionsScreenCoordinator()
|
||||||
|
parameters.navigationStackCoordinator?.push(coordinator)
|
||||||
|
}
|
||||||
|
|
||||||
private func showSuccess(label: String) {
|
private func showSuccess(label: String) {
|
||||||
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
|
parameters.userIndicatorController?.submitIndicator(UserIndicator(title: label))
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ enum SettingsScreenViewModelAction {
|
|||||||
case toggleAnalytics
|
case toggleAnalytics
|
||||||
case reportBug
|
case reportBug
|
||||||
case sessionVerification
|
case sessionVerification
|
||||||
|
case developerOptions
|
||||||
case logout
|
case logout
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ struct SettingsScreenViewState: BindableState {
|
|||||||
var userAvatarURL: URL?
|
var userAvatarURL: URL?
|
||||||
var userDisplayName: String?
|
var userDisplayName: String?
|
||||||
var showSessionVerificationSection: Bool
|
var showSessionVerificationSection: Bool
|
||||||
|
var showDeveloperOptions: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SettingsScreenViewStateBindings {
|
struct SettingsScreenViewStateBindings {
|
||||||
@@ -45,4 +47,5 @@ enum SettingsScreenViewAction {
|
|||||||
case sessionVerification
|
case sessionVerification
|
||||||
case logout
|
case logout
|
||||||
case changedTimelineStyle
|
case changedTimelineStyle
|
||||||
|
case developerOptions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,15 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
|||||||
private let userSession: UserSessionProtocol
|
private let userSession: UserSessionProtocol
|
||||||
|
|
||||||
var callback: ((SettingsScreenViewModelAction) -> Void)?
|
var callback: ((SettingsScreenViewModelAction) -> Void)?
|
||||||
|
|
||||||
init(withUserSession userSession: UserSessionProtocol) {
|
init(withUserSession userSession: UserSessionProtocol) {
|
||||||
self.userSession = userSession
|
self.userSession = userSession
|
||||||
let bindings = SettingsScreenViewStateBindings(timelineStyle: ServiceLocator.shared.settings.timelineStyle)
|
let bindings = SettingsScreenViewStateBindings(timelineStyle: ServiceLocator.shared.settings.timelineStyle)
|
||||||
super.init(initialViewState: .init(bindings: bindings,
|
super.init(initialViewState: .init(bindings: bindings,
|
||||||
deviceID: userSession.deviceId,
|
deviceID: userSession.deviceId,
|
||||||
userID: userSession.userID,
|
userID: userSession.userID,
|
||||||
showSessionVerificationSection: !(userSession.sessionVerificationController?.isVerified ?? false)),
|
showSessionVerificationSection: !(userSession.sessionVerificationController?.isVerified ?? false),
|
||||||
|
showDeveloperOptions: ServiceLocator.shared.settings.canShowDeveloperOptions),
|
||||||
imageProvider: userSession.mediaProvider)
|
imageProvider: userSession.mediaProvider)
|
||||||
|
|
||||||
ServiceLocator.shared.settings.$timelineStyle
|
ServiceLocator.shared.settings.$timelineStyle
|
||||||
@@ -78,6 +79,8 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
|||||||
callback?(.sessionVerification)
|
callback?(.sessionVerification)
|
||||||
case .changedTimelineStyle:
|
case .changedTimelineStyle:
|
||||||
ServiceLocator.shared.settings.timelineStyle = state.bindings.timelineStyle
|
ServiceLocator.shared.settings.timelineStyle = state.bindings.timelineStyle
|
||||||
|
case .developerOptions:
|
||||||
|
callback?(.developerOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import SwiftUI
|
|||||||
|
|
||||||
struct SettingsScreen: View {
|
struct SettingsScreen: View {
|
||||||
@State private var showingLogoutConfirmation = false
|
@State private var showingLogoutConfirmation = false
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
|
||||||
|
|
||||||
@ScaledMetric private var avatarSize = AvatarSize.user(on: .settings).value
|
@ScaledMetric private var avatarSize = AvatarSize.user(on: .settings).value
|
||||||
@ScaledMetric private var menuIconSize = 30.0
|
@ScaledMetric private var menuIconSize = 30.0
|
||||||
@@ -40,6 +39,11 @@ struct SettingsScreen: View {
|
|||||||
simplifiedSection
|
simplifiedSection
|
||||||
.listRowBackground(Color.element.formRowBackground)
|
.listRowBackground(Color.element.formRowBackground)
|
||||||
|
|
||||||
|
if context.viewState.showDeveloperOptions {
|
||||||
|
developerOptionsSection
|
||||||
|
.listRowBackground(Color.element.formRowBackground)
|
||||||
|
}
|
||||||
|
|
||||||
signOutSection
|
signOutSection
|
||||||
.listRowBackground(Color.element.formRowBackground)
|
.listRowBackground(Color.element.formRowBackground)
|
||||||
}
|
}
|
||||||
@@ -89,6 +93,16 @@ struct SettingsScreen: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var developerOptionsSection: some View {
|
||||||
|
Section {
|
||||||
|
SettingsDefaultRow(title: ElementL10n.settingsDeveloperOptions,
|
||||||
|
image: Image(systemName: "hammer.circle")) {
|
||||||
|
context.send(viewAction: .developerOptions)
|
||||||
|
}
|
||||||
|
.accessibilityIdentifier("sessionVerificationButton")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var simplifiedSection: some View {
|
private var simplifiedSection: some View {
|
||||||
Section {
|
Section {
|
||||||
SettingsPickerRow(title: ElementL10n.settingsTimelineStyle,
|
SettingsPickerRow(title: ElementL10n.settingsTimelineStyle,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// 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 ElementX
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class DeveloperOptionsScreenScreenUITests: XCTestCase { }
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// 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 XCTest
|
||||||
|
|
||||||
|
@testable import ElementX
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
class DeveloperOptionsScreenViewModelTests: XCTestCase { }
|
||||||
Reference in New Issue
Block a user