diff --git a/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/ShowCodeView.swift b/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/ShowCodeView.swift deleted file mode 100644 index b2db427eef..0000000000 --- a/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/ShowCodeView.swift +++ /dev/null @@ -1,44 +0,0 @@ -// -// ShowCodeView.swift -// DuckDuckGo -// -// Copyright © 2023 DuckDuckGo. All rights reserved. -// -// 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 ShowCodeView: View { -// -// let code: String -// let copyCode: () -> Void -// -// var body: some View { -// -// List { -// Text(code) -// .monospaceSystemFont(ofSize: 16) -// -// Button { -// copyCode() -// } label: { -// Label("Copy Code", image: "SyncCopy") -// } -// } -// .lineSpacing(1.47) -// .navigationTitle("Code") -// .applyListStyle() -// } -// -//} diff --git a/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/UserText.swift b/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/UserText.swift index cf2439d9fd..e570f2e5d2 100644 --- a/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/UserText.swift +++ b/LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/UserText.swift @@ -100,6 +100,15 @@ struct UserText { static let cameraIsUnavailableTitle = NSLocalizedString("camera.is.unavailable.title", value: "Camera is Unavailable", comment: "Camera View - Unavailable Title") static let cameraGoToSettingsButton = NSLocalizedString("camera.go.to.settings.button", value: "Go to Settings", comment: "Camera View - Go to Settings Button") +// Manually Enter Code View + static let manuallyEnterCodeTitle = "Enter Text Code" + static let manuallyEnterCodeValidatingCodeAction = "Validating code" + static let manuallyEnterCodeValidatingCodeFailedAction = "Invalid code." + static let manuallyEnterCodeInstructionPart1 = "Go to " + static let manuallyEnterCodeInstructionPart2 = "Settings > Sync & Backup > Sync With Another Device " + static let manuallyEnterCodeInstructionPart3 = "and select " + static let manuallyEnterCodeInstructionPart4 = "View Text Code " + static let manuallyEnterCodeInstructionPart5 = "in the DuckDuckGo App on another synced device and paste the code here to sync this device." static let scanQRCode = "Scan QR Code" static let enterTextCode = "Enter Text Code" @@ -115,9 +124,6 @@ struct UserText { static let recoveryModeInstructions = "Scan the QR code on your Recovery PDF, or another synced device, to recover your data." - static let validatingCode = "Validating code" - static let validatingCodeFailed = "Invalid code." - static let pasteCodeInstructions = "Copy the code from the\n Settings > Sync & Back Up page in the DuckDuckGo App on another synced device and paste it here to sync this device." static let viewQRCodeInstructions = "Open the DuckDuckGo app on another device. Navigate to Settings > Sync & Back Up and scan this QR code." @@ -134,11 +140,8 @@ struct UserText { static let thisDevice = "This Device" - - static let pasteLabel = "Paste" static let copyCodeLabel = "Copy Code" - static let manuallyEnterCodeTitle = "Enter Text Code" static let showQRCodeLabel = "Show QR Code" static let showQRCodeSubLabel = "Display code to scan with another device" @@ -153,12 +156,13 @@ struct UserText { // Standard Buttons static let cancelButton = "Cancel" - - static let removeButton = "Remove" static let doneButton = "Done" static let nextButton = "Next" - static let notNowButton = "Not Now" static let backButton = "Back" + static let pasteButton = "Paste" + + static let removeButton = "Remove" + static let notNowButton = "Not Now" static let editDeviceLabel = "Device Name" static func editDevice(_ name: String) -> String { diff --git a/LocalPackages/SyncUI/Sources/SyncUI/Views/PasteCodeView.swift b/LocalPackages/SyncUI/Sources/SyncUI/Views/PasteCodeView.swift index 2eca97e13b..d19fcf9698 100644 --- a/LocalPackages/SyncUI/Sources/SyncUI/Views/PasteCodeView.swift +++ b/LocalPackages/SyncUI/Sources/SyncUI/Views/PasteCodeView.swift @@ -30,17 +30,14 @@ public struct PasteCodeView: View { @State var isEditingCode = false - var isFirstScreen: Bool - - public init(model: ScanOrPasteCodeViewModel, isfirstScreen: Bool = false) { + public init(model: ScanOrPasteCodeViewModel) { self.model = model - self.isFirstScreen = isfirstScreen } @ViewBuilder func pasteButton() -> some View { Button(action: model.pasteCode) { - Label(UserText.pasteLabel, image: "SyncPaste") + Label(UserText.pasteButton, image: "SyncPaste") } } @@ -67,14 +64,14 @@ public struct PasteCodeView: View { if model.isValidating { HStack(spacing: 4) { SwiftUI.ProgressView() - Text(UserText.validatingCode) + Text(UserText.manuallyEnterCodeValidatingCodeAction) .foregroundColor(.white.opacity(0.36)) } .padding(.horizontal) } else if model.invalidCode { HStack { Image("SyncAlert") - Text(UserText.validatingCodeFailed) + Text(UserText.manuallyEnterCodeValidatingCodeFailedAction) .foregroundColor(.white.opacity(0.36)) } .padding(.horizontal) @@ -97,13 +94,22 @@ public struct PasteCodeView: View { @ViewBuilder func instructions() -> some View { - Text(UserText.pasteCodeInstructions) + instructionsText() .lineLimit(nil) .multilineTextAlignment(.center) .foregroundColor(.white.opacity(0.6)) .padding() } + func instructionsText() -> some View { + (Text(UserText.manuallyEnterCodeInstructionPart1) + + Text(UserText.manuallyEnterCodeInstructionPart2).bold() + + Text(UserText.manuallyEnterCodeInstructionPart3) + + Text(UserText.manuallyEnterCodeInstructionPart4).bold() + + Text(UserText.manuallyEnterCodeInstructionPart5) + ) + } + @ViewBuilder func pastCodeWiewWithNoModifier() -> some View { ZStack(alignment: .top) { @@ -119,13 +125,9 @@ public struct PasteCodeView: View { } public var body: some View { - if isFirstScreen { - pastCodeWiewWithNoModifier() - .modifier(CancelButtonModifier(action: model.cancel)) - } else { - pastCodeWiewWithNoModifier() - .modifier(BackButtonModifier()) - } + pastCodeWiewWithNoModifier() + .modifier(BackButtonModifier()) + } } diff --git a/LocalPackages/SyncUI/Sources/SyncUI/Views/ScanOrPasteCodeView.swift b/LocalPackages/SyncUI/Sources/SyncUI/Views/ScanOrPasteCodeView.swift index 017740fb9d..bbbc82a350 100644 --- a/LocalPackages/SyncUI/Sources/SyncUI/Views/ScanOrPasteCodeView.swift +++ b/LocalPackages/SyncUI/Sources/SyncUI/Views/ScanOrPasteCodeView.swift @@ -85,7 +85,7 @@ public struct ScanOrPasteCodeView: View { } label: { HStack { Image("SyncGotoButton") - Text(UserText.goToSettingsButton) + Text(UserText.cameraGoToSettingsButton) } } .buttonStyle(SyncLabelButtonStyle()) diff --git a/LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsView.swift b/LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsView.swift index bbfdf8b8bb..5f66c8c609 100644 --- a/LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsView.swift +++ b/LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsView.swift @@ -94,7 +94,7 @@ extension SyncSettingsView { @ViewBuilder func syncWithAnotherDeviceView() -> some View { Section { - VStack(spacing: 8) { + VStack(alignment: .center, spacing: 8) { Image("Sync-Pair-96") Text(UserText.syncWithAnotherDeviceTitle) .daxTitle3() @@ -178,6 +178,27 @@ extension SyncSettingsView { } } + + @ViewBuilder + func devicesList() -> some View { + ForEach(model.devices) { device in + Button { + selectedDevice = device + } label: { + HStack { + deviceTypeImage(device) + Text(device.name) + .foregroundColor(.primary) + Spacer() + if device.isThisDevice { + Text(UserText.syncedDevicesThisDeviceLabel) + .foregroundColor(.secondary) + } + } + } + } + } + @ViewBuilder func devices() -> some View { Section { @@ -185,23 +206,7 @@ extension SyncSettingsView { ProgressView() .padding() } - - ForEach(model.devices) { device in - Button { - selectedDevice = device - } label: { - HStack { - deviceTypeImage(device) - Text(device.name) - .foregroundColor(.primary) - Spacer() - if device.isThisDevice { - Text(UserText.syncedDevicesThisDeviceLabel) - .foregroundColor(.secondary) - } - } - } - } + devicesList() Button(action: { model.scanQRCode() }, label: { @@ -232,7 +237,6 @@ extension SyncSettingsView { model.delegate?.refreshDevices(clearDevices: false) } } - } @ViewBuilder