Skip to content

Commit

Permalink
rollback appearance preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
mallexxx committed Nov 14, 2024
1 parent 457b59d commit e6cb52b
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Rocket-16.svg",
"idiom" : "universal",
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ struct UserText {
static let newTabBottomPopoverTitle = NSLocalizedString("newTab.bottom.popover.title", value: "New Tab Page", comment: "Title of the popover that appears when pressing the bottom right button")
static let newTabMenuItemShowSearchBar = NSLocalizedString("newTab.menu.item.show.search.bar", value: "Show Search Box", comment: "Title of the menu item in the home page to show/hide search box (search field)")
static let newTabMenuItemShowFavorite = NSLocalizedString("newTab.menu.item.show.favorite", value: "Show Favorites", comment: "Title of the menu item in the home page to show/hide favorite section")
static let newTabMenuItemShowContinuteSetUp = NSLocalizedString("newTab.menu.item.show.continue.setup", value: "Show Next Steps", comment: "Title of the menu item in the home page to show/hide continue setup section")
static let newTabMenuItemShowRecentActivity = NSLocalizedString("newTab.menu.item.show.recent.activity", value: "Show Recent Activity", comment: "Title of the menu item in the home page to show/hide recent activity section")

// Search Bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import SwiftUIExtensions
extension HomePage.Views {

struct HomeContentSectionsView: View {
let includeContinueSetUpCards: Bool
@EnvironmentObject var model: AppearancePreferences
@EnvironmentObject var addressBarModel: HomePage.Models.AddressBarModel
@EnvironmentObject var continueSetUpModel: HomePage.Models.ContinueSetUpModel
Expand All @@ -41,6 +42,19 @@ extension HomePage.Views {
.toggleStyle(.switch)
}

if includeContinueSetUpCards {
Toggle(isOn: $model.isContinueSetUpVisible) {
HStack {
Image(.rocketGrayscale)
.frame(width: iconSize, height: iconSize)
Text(UserText.newTabSetUpSectionTitle)
Spacer()
}
}
.toggleStyle(.switch)
.visibility(continueSetUpModel.hasContent ? .visible : .gone)
}

Toggle(isOn: $model.isFavoriteVisible) {
HStack {
Image(.favorite)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extension HomePage.Views {
static let sectionSpacing = 36.0
}

let includingContinueSetUpCards: Bool
@EnvironmentObject var model: HomePage.Models.SettingsModel
@EnvironmentObject var appearancePreferences: AppearancePreferences
@EnvironmentObject var continueSetUpModel: HomePage.Models.ContinueSetUpModel
Expand Down Expand Up @@ -174,7 +175,7 @@ extension HomePage.Views {
ThemePicker()
}
SettingsSection(title: UserText.homePageSections) {
HomeContentSectionsView()
HomeContentSectionsView(includeContinueSetUpCards: includingContinueSetUpCards)
}
rootViewFooter
}
Expand Down Expand Up @@ -232,13 +233,42 @@ extension HomePage.Views.BackgroundCategoryView {
}

#if DEBUG
#Preview {
#Preview("including continue set up cards") {
@State var isSettingsVisible: Bool = true

let settingsModel = HomePage.Models.SettingsModel()
settingsModel.customBackground = .solidColor(.color10)

return HomePage.Views.SettingsView( isSettingsVisible: $isSettingsVisible)
return HomePage.Views.SettingsView(includingContinueSetUpCards: true, isSettingsVisible: $isSettingsVisible)
.frame(width: 236, height: 600)
.environmentObject(settingsModel)
.environmentObject(AppearancePreferences.shared)
.environmentObject(HomePage.Models.ContinueSetUpModel(
defaultBrowserProvider: SystemDefaultBrowserProvider(),
dockCustomizer: DockCustomizer(),
dataImportProvider: BookmarksAndPasswordsImportStatusProvider(),
tabCollectionViewModel: TabCollectionViewModel(),
duckPlayerPreferences: DuckPlayerPreferencesUserDefaultsPersistor()
))
.environmentObject(HomePage.Models.FavoritesModel(
open: { _, _ in },
removeFavorite: { _ in },
deleteBookmark: { _ in },
add: {},
edit: { _ in },
moveFavorite: { _, _ in },
onFaviconMissing: {}
))
.environmentObject(HomePage.Models.AddressBarModel(tabCollectionViewModel: TabCollectionViewModel(), privacyConfigurationManager: MockPrivacyConfigurationManager()))
}

#Preview("no continue set up cards") {
@State var isSettingsVisible: Bool = true

let settingsModel = HomePage.Models.SettingsModel()
settingsModel.customBackground = .solidColor(.color10)

return HomePage.Views.SettingsView(includingContinueSetUpCards: false, isSettingsVisible: $isSettingsVisible)
.frame(width: 236, height: 600)
.environmentObject(settingsModel)
.environmentObject(AppearancePreferences.shared)
Expand Down
8 changes: 7 additions & 1 deletion DuckDuckGo/HomePage/View/HomePageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ extension HomePage.Views {
.contextMenu(menuItems: sectionsVisibilityContextMenuItems)

if settingsVisibilityModel.isSettingsVisible {
SettingsView(isSettingsVisible: $settingsVisibilityModel.isSettingsVisible)
SettingsView(includingContinueSetUpCards: model.isContinueSetUpAvailable && !model.isContinueSetUpCardsViewOutdated,
isSettingsVisible: $settingsVisibilityModel.isSettingsVisible)
.frame(width: Self.settingsPanelWidth)
.transition(.move(edge: .trailing))
.layoutPriority(1)
Expand Down Expand Up @@ -239,6 +240,11 @@ extension HomePage.Views {
Toggle(UserText.newTabMenuItemShowSearchBar, isOn: $model.isSearchBarVisible)
.toggleStyle(.checkbox)
}
if model.isContinueSetUpAvailable && !model.isContinueSetUpCardsViewOutdated {
Toggle(UserText.newTabMenuItemShowContinuteSetUp, isOn: $model.isContinueSetUpVisible)
.toggleStyle(.checkbox)
.visibility(continueSetUpModel.hasContent ? .visible : .gone)
}
Toggle(UserText.newTabMenuItemShowFavorite, isOn: $model.isFavoriteVisible)
.toggleStyle(.checkbox)
Toggle(UserText.newTabMenuItemShowRecentActivity, isOn: $model.isRecentActivityVisible)
Expand Down
Loading

0 comments on commit e6cb52b

Please sign in to comment.