Skip to content

Commit

Permalink
design adjustments and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx committed Dec 12, 2023
1 parent 4a6f627 commit c1ddad4
Show file tree
Hide file tree
Showing 9 changed files with 434 additions and 134 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/DataImport/View/DataImportErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct DataImportErrorView: View {
VStack(alignment: .leading, spacing: 8) {
Text("We were unable to import \(dataType.displayName) directly from \(source.importSourceName).",
comment: "Message when data import fails from a browser. %1$@ - Bookmarks or Passwords; %2$@ - a browser name")
.font(.headline)
.bold()

Text("Let’s try doing it manually. It won’t take long.",
comment: "Suggestion to switch to a Manual File Data Import when data import fails.")
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/DataImport/View/DataImportNoDataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct DataImportNoDataView: View {
var body: some View {
VStack(alignment: .leading, spacing: 8) {
Text("We couldn‘t find any \(dataType.displayName)", comment: "Data import error message: Bookmarks or Passwords (%@) weren‘t found.")
.font(.headline)
.bold()

Text("You could try importing \(dataType.displayName) manually.",
comment: "Data import error subtitle: suggestion to import Bookmarks or Passwords (%@) manually by selecting a CSV or HTML file.")
Expand Down
29 changes: 14 additions & 15 deletions DuckDuckGo/DataImport/View/DataImportProfilePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,20 @@ struct DataImportProfilePicker: View {

var body: some View {
VStack(alignment: .leading, spacing: 10) {
if profiles.count > 1 {
Text("Select Profile:", comment: "Browser Profile picker title for Data Import")
.font(.headline)
Text("Select Profile:", comment: "Browser Profile picker title for Data Import")
.bold()

Picker(selection: Binding {
selectedProfile.flatMap(profiles.firstIndex(of:)) ?? 0
} set: {
selectedProfile = profiles[safe: $0]
}) {
ForEach(profiles.indices, id: \.self) { idx in
Text(profiles[idx].profileName)
}
} label: {}
.pickerStyle(.menu)
.controlSize(.large)
}
Picker(selection: Binding {
selectedProfile.flatMap(profiles.firstIndex(of:)) ?? 0
} set: {
selectedProfile = profiles[safe: $0]
}) {
ForEach(profiles.indices, id: \.self) { idx in
Text(profiles[idx].profileName)
}
} label: {}
.pickerStyle(.menu)
.controlSize(.large)
}
}

Expand All @@ -67,4 +65,5 @@ struct DataImportProfilePicker: View {
})
.padding()
.frame(width: 512)
.font(.custom("SF Pro Text", size: 13))
}
35 changes: 24 additions & 11 deletions DuckDuckGo/DataImport/View/DataImportSummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,34 @@ struct DataImportSummaryView: View {
case .fileImportComplete(.passwords):
Text("Password import complete. You can now delete the saved passwords file.", comment: "message about Passwords Data Import completion")
}
}().padding(.bottom, 16)
}().padding(.bottom, 4)

ForEach(model.results, id: \.dataType) { item in
switch (item.dataType, item.result) {
case (.bookmarks, .success(let summary)):
HStack {
successImage()
Text("Bookmarks: \(summary.successful)",
Text("Bookmarks:",
comment: "Data import summary format of how many bookmarks (%lld) were successfully imported.")
+ Text(" " as String)
+ Text(String(summary.successful)).bold()
}
if summary.duplicate > 0 {
HStack {
failureImage()
Text("Duplicate Bookmarks Skipped: \(summary.duplicate)",
Text("Duplicate Bookmarks Skipped:",
comment: "Data import summary format of how many duplicate bookmarks (%lld) were skipped during import.")
+ Text(" " as String)
+ Text(String(summary.duplicate)).bold()
}
}
if summary.failed > 0 {
HStack {
failureImage()
Text("Bookmark import failed: \(summary.failed)",
Text("Bookmark import failed:",
comment: "Data import summary format of how many bookmarks (%lld) failed to import.")
+ Text(" " as String)
+ Text(String(summary.failed)).bold()
}
}

Expand All @@ -89,14 +95,18 @@ struct DataImportSummaryView: View {
case (.passwords, .success(let summary)):
HStack {
successImage()
Text("Passwords: \(summary.successful)",
Text("Passwords:",
comment: "Data import summary format of how many passwords (%lld) were successfully imported.")
+ Text(" " as String)
+ Text(String(summary.successful)).bold()
}
if summary.failed > 0 {
HStack {
failureImage()
Text("Passwords import failed: \(summary.failed)",
Text("Passwords import failed: ",
comment: "Data import summary format of how many passwords (%lld) failed to import.")
+ Text(" " as String)
+ Text(String(summary.failed)).bold()
}
}
}
Expand All @@ -118,11 +128,14 @@ private func failureImage() -> some View {

#Preview {
VStack {
DataImportSummaryView(model: .init(source: .chrome, summary: [
.bookmarks: .success(.init(successful: 123, duplicate: 456, failed: 7890)),
.passwords: .success(.init(successful: 123, duplicate: 456, failed: 7890))
]))
.padding(EdgeInsets(top: 20, leading: 20, bottom: 16, trailing: 20))
HStack {
DataImportSummaryView(model: .init(source: .chrome, summary: [
.bookmarks: .success(.init(successful: 123, duplicate: 456, failed: 7890)),
.passwords: .success(.init(successful: 123, duplicate: 456, failed: 7890))
]))
.padding(EdgeInsets(top: 20, leading: 20, bottom: 16, trailing: 20))
Spacer()
}
}
.frame(width: 512)
}
2 changes: 1 addition & 1 deletion DuckDuckGo/DataImport/View/DataImportTypePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct DataImportTypePicker: View {
VStack(alignment: .leading) {
Text("Select data to import:",
comment: "Data Import section title for checkboxes of data type to import: Passwords or Bookmarks.")
.font(.headline)
.bold()

ForEach(DataImport.DataType.allCases, id: \.self) { dataType in
// display all types for a browser disabling unavailable options
Expand Down
29 changes: 17 additions & 12 deletions DuckDuckGo/DataImport/View/DataImportView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ struct DataImportView: View {
.padding(.trailing, 20)
.padding(.bottom, 32)

// if import in progress…
if let importProgress = model.importProgress {
progressView(importProgress)
}

Divider()

viewFooter()
Expand All @@ -78,14 +83,15 @@ struct DataImportView: View {
}
#endif
}
.font(.custom("SF Pro Text", size: 13))
.frame(width: 512)
.fixedSize()
}

private func viewHeader() -> some View {
VStack(alignment: .leading, spacing: 0) {
Text(UserText.importDataTitle)
.font(.headline)
.bold()
.padding(.bottom, 16)

// browser to import data from picker popup
Expand All @@ -105,10 +111,12 @@ struct DataImportView: View {
switch model.screen {
case .profileAndDataTypesPicker:
// Browser Profile picker
DataImportProfilePicker(profileList: model.browserProfiles,
selectedProfile: $model.selectedProfile)
.disabled(model.isImportSourcePickerDisabled)
.padding(.bottom, 24)
if model.browserProfiles?.validImportableProfiles.count ?? 0 > 1 {
DataImportProfilePicker(profileList: model.browserProfiles,
selectedProfile: $model.selectedProfile)
.disabled(model.isImportSourcePickerDisabled)
.padding(.bottom, 24)
}

// Bookmarks/Passwords checkboxes
DataImportTypePicker(viewModel: $model)
Expand All @@ -129,9 +137,10 @@ struct DataImportView: View {
if !summaryTypes.isEmpty {
DataImportSummaryView(model, dataTypes: summaryTypes)
.padding(.bottom, 24)
}

// if no data to import
} else if model.summary(for: dataType)?.isEmpty == true
if model.summary(for: dataType)?.isEmpty == true
|| model.error(for: dataType)?.errorType == .noData {

DataImportNoDataView(source: model.importSource, dataType: dataType)
Expand Down Expand Up @@ -159,11 +168,6 @@ struct DataImportView: View {

ReportFeedbackView(model: $model.reportModel)
}

// Import in progress…
if let importProgress = model.importProgress {
progressView(importProgress)
}
}
}

Expand Down Expand Up @@ -459,7 +463,7 @@ extension DataImportViewModel.ButtonType {
}
}

let viewModel = DataImportViewModel(importSource: .chrome) { browser in
let viewModel = DataImportViewModel(importSource: .bookmarksHTML) { browser in
guard case .chrome = browser else {
print("empty profiles")
return .init(browser: browser, profiles: [])
Expand Down Expand Up @@ -514,6 +518,7 @@ extension DataImportViewModel.ButtonType {
})

PreviewPreferencesView()
Spacer()
}
.frame(minHeight: 666)

Expand Down
Loading

0 comments on commit c1ddad4

Please sign in to comment.