Skip to content

Commit

Permalink
clean manually enter code view
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Nov 27, 2023
1 parent 4760be6 commit 5d45bc6
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 88 deletions.

This file was deleted.

22 changes: 13 additions & 9 deletions LocalPackages/SyncUI/Sources/SyncUI/Views/Internal/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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."
Expand All @@ -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"
Expand All @@ -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 {
Expand Down
32 changes: 17 additions & 15 deletions LocalPackages/SyncUI/Sources/SyncUI/Views/PasteCodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand All @@ -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)
Expand All @@ -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) {
Expand All @@ -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())

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public struct ScanOrPasteCodeView: View {
} label: {
HStack {
Image("SyncGotoButton")
Text(UserText.goToSettingsButton)
Text(UserText.cameraGoToSettingsButton)
}
}
.buttonStyle(SyncLabelButtonStyle())
Expand Down
42 changes: 23 additions & 19 deletions LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -178,30 +178,35 @@ 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 {
if model.devices.isEmpty {
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: {
Expand Down Expand Up @@ -232,7 +237,6 @@ extension SyncSettingsView {
model.delegate?.refreshDevices(clearDevices: false)
}
}

}

@ViewBuilder
Expand Down

0 comments on commit 5d45bc6

Please sign in to comment.