Skip to content

Commit

Permalink
clean up scan or view code
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Nov 27, 2023
1 parent 5d45bc6 commit c041451
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 479 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate {

var controller: UIHostingController<AnyView>
if showConnectMode {
controller = UIHostingController(rootView: AnyView(ScanOrPasteCodeView(model: model)))
controller = UIHostingController(rootView: AnyView(ScanOrSeeCode(model: model)))
} else {
controller = UIHostingController(rootView: AnyView(ScanOrEnterCodeToRecoverSyncedData(model: model)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
// limitations under the License.
//

import SwiftUI

/// We have to defer starting connect mode untl we're visible because otherwise SwiftUI might start it prematurely as a result of the NavigationLink.
/// In iOS 16 we use a value binding on the NavigationLink, but this better anyway as we can show progress.
struct ConnectModeView: View {

@ObservedObject var model: ScanOrPasteCodeViewModel
@State var qrCodeModel = ShowQRCodeViewModel()

var body: some View {
QRCodeCopierView(model: qrCodeModel)
.padding(.vertical, 20)
.frame(maxWidth: Constants.maxFullScreenWidth)
.onAppear {
self.qrCodeModel = model.startConnectMode()
}
}

}
//import SwiftUI
//
///// We have to defer starting connect mode untl we're visible because otherwise SwiftUI might start it prematurely as a result of the NavigationLink.
///// In iOS 16 we use a value binding on the NavigationLink, but this better anyway as we can show progress.
//struct ConnectModeView: View {
//
// @ObservedObject var model: ScanOrPasteCodeViewModel
// @State var qrCodeModel = ShowQRCodeViewModel()
//
// var body: some View {
// QRCodeCopierView(model: qrCodeModel)
// .padding(.vertical, 20)
// .frame(maxWidth: Constants.maxFullScreenWidth)
// .onAppear {
// self.qrCodeModel = model.startConnectMode()
// }
// }
//
//}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ struct EditDeviceView: View {
Section {
TextField("", text: $model.name)
} header: {
Text(UserText.editDeviceLabel)
Text(UserText.editDeviceHeader)
}
}
.applyListStyle()
.navigationTitle(UserText.editDevice(model.name))
.navigationTitle(UserText.editDeviceTitle(model.name))
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,81 +20,81 @@
import SwiftUI
import DesignResourcesKit

struct QRCodeCopierView: View {

@ObservedObject var model: ShowQRCodeViewModel

@ViewBuilder
func progressView() -> some View {
if model.code == nil {
ZStack {
SwiftUI.ProgressView()
}.frame(width: 200, height: 200)
}
}

@ViewBuilder
func qrCodeView() -> some View {
if let code = model.code {
VStack(spacing: 20) {
Spacer()

QRCodeView(string: code, size: 220)
.padding()

Spacer()

Button {
model.copy()
} label: {
Label(UserText.copyCodeLabel, image: "SyncCopy")
}
.buttonStyle(SyncLabelButtonStyle())
.padding(.bottom, 20)
}
}
}

@ViewBuilder
func instructions() -> some View {

if model.code != nil {
Text(UserText.viewQRCodeInstructions)
.daxCaption()
.foregroundColor(.secondary)
.lineLimit(nil)
.multilineTextAlignment(.center)
}

}

@ViewBuilder
func qrCodeSection() -> some View {
ZStack {
VStack {
HStack { Spacer() }
Spacer()
}
RoundedRectangle(cornerRadius: 8).foregroundColor(.white.opacity(0.12))
progressView()
qrCodeView()
}
.frame(maxWidth: 350, maxHeight: 350)
.padding()
}

var body: some View {
ZStack(alignment: .top) {
VStack(spacing: 20) {
qrCodeSection()
instructions()
Spacer()
}
.padding(.horizontal, 20)
.frame(maxWidth: Constants.maxFullScreenWidth, alignment: .center)
}
.navigationTitle(UserText.viewQRCodeTitle)
.modifier(BackButtonModifier())
}

}
//struct QRCodeCopierView: View {
//
// @ObservedObject var model: ShowQRCodeViewModel
//
// @ViewBuilder
// func progressView() -> some View {
// if model.code == nil {
// ZStack {
// SwiftUI.ProgressView()
// }.frame(width: 200, height: 200)
// }
// }
//
// @ViewBuilder
// func qrCodeView() -> some View {
// if let code = model.code {
// VStack(spacing: 20) {
// Spacer()
//
// QRCodeView(string: code, size: 220)
// .padding()
//
// Spacer()
//
// Button {
// model.copy()
// } label: {
// Label(UserText.copyCodeLabel, image: "SyncCopy")
// }
// .buttonStyle(SyncLabelButtonStyle())
// .padding(.bottom, 20)
// }
// }
// }
//
// @ViewBuilder
// func instructions() -> some View {
//
// if model.code != nil {
// Text(UserText.viewQRCodeInstructions)
// .daxCaption()
// .foregroundColor(.secondary)
// .lineLimit(nil)
// .multilineTextAlignment(.center)
// }
//
// }
//
// @ViewBuilder
// func qrCodeSection() -> some View {
// ZStack {
// VStack {
// HStack { Spacer() }
// Spacer()
// }
// RoundedRectangle(cornerRadius: 8).foregroundColor(.white.opacity(0.12))
// progressView()
// qrCodeView()
// }
// .frame(maxWidth: 350, maxHeight: 350)
// .padding()
// }
//
// var body: some View {
// ZStack(alignment: .top) {
// VStack(spacing: 20) {
// qrCodeSection()
// instructions()
// Spacer()
// }
// .padding(.horizontal, 20)
// .frame(maxWidth: Constants.maxFullScreenWidth, alignment: .center)
// }
// .navigationTitle(UserText.viewQRCodeTitle)
// .modifier(BackButtonModifier())
// }
//
//}
Loading

0 comments on commit c041451

Please sign in to comment.