-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Tab Page Shortcuts section #3104
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ebb9592
Add shortcut assets
dus7 0bae98c
Define shortcut entity
dus7 2b10b7e
Define editing accessory view for shortcuts
dus7 99bc604
Define basic model with in-memory storage
dus7 38af09a
Add shortcut redirection
dus7 cbb40c8
Move Preview to bottom
dus7 349fe31
Extract constant
dus7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,10 @@ | |
6F40D15E2C34436500BF22F0 /* HomePageDisplayDailyPixelBucketTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F40D15C2C34436200BF22F0 /* HomePageDisplayDailyPixelBucketTests.swift */; }; | ||
6F5CC0812C2AFFE400AFC840 /* ToggleExpandButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5CC0802C2AFFE400AFC840 /* ToggleExpandButtonView.swift */; }; | ||
6F64AA532C47E92600CF4489 /* FavoritesFaviconLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F64AA522C47E92600CF4489 /* FavoritesFaviconLoader.swift */; }; | ||
6F64AA592C4818D700CF4489 /* NewTabPageShortcut.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F64AA582C4818D700CF4489 /* NewTabPageShortcut.swift */; }; | ||
6F64AA5B2C481AAA00CF4489 /* Shortcuts.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F64AA5A2C481AAA00CF4489 /* Shortcuts.xcassets */; }; | ||
6F64AA5D2C4920D200CF4489 /* ShortcutAccessoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F64AA5C2C4920D200CF4489 /* ShortcutAccessoryView.swift */; }; | ||
6F64AA5F2C49463C00CF4489 /* ShortcutsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F64AA5E2C49463C00CF4489 /* ShortcutsModel.swift */; }; | ||
6F655BE22BAB289E00AC3597 /* DefaultTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F655BE12BAB289E00AC3597 /* DefaultTheme.swift */; }; | ||
6F8496412BC3D8EE00ADA54E /* OnboardingButtonsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F8496402BC3D8EE00ADA54E /* OnboardingButtonsView.swift */; }; | ||
6F96FF102C2B128500162692 /* NewTabPageCustomizeButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F96FF0F2C2B128500162692 /* NewTabPageCustomizeButtonView.swift */; }; | ||
|
@@ -1405,6 +1409,10 @@ | |
6F40D15C2C34436200BF22F0 /* HomePageDisplayDailyPixelBucketTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomePageDisplayDailyPixelBucketTests.swift; sourceTree = "<group>"; }; | ||
6F5CC0802C2AFFE400AFC840 /* ToggleExpandButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleExpandButtonView.swift; sourceTree = "<group>"; }; | ||
6F64AA522C47E92600CF4489 /* FavoritesFaviconLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesFaviconLoader.swift; sourceTree = "<group>"; }; | ||
6F64AA582C4818D700CF4489 /* NewTabPageShortcut.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageShortcut.swift; sourceTree = "<group>"; }; | ||
6F64AA5A2C481AAA00CF4489 /* Shortcuts.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Shortcuts.xcassets; sourceTree = "<group>"; }; | ||
6F64AA5C2C4920D200CF4489 /* ShortcutAccessoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutAccessoryView.swift; sourceTree = "<group>"; }; | ||
6F64AA5E2C49463C00CF4489 /* ShortcutsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsModel.swift; sourceTree = "<group>"; }; | ||
6F655BE12BAB289E00AC3597 /* DefaultTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultTheme.swift; sourceTree = "<group>"; }; | ||
6F8496402BC3D8EE00ADA54E /* OnboardingButtonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingButtonsView.swift; sourceTree = "<group>"; }; | ||
6F96FF0F2C2B128500162692 /* NewTabPageCustomizeButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageCustomizeButtonView.swift; sourceTree = "<group>"; }; | ||
|
@@ -3569,6 +3577,10 @@ | |
children = ( | ||
6FE1273F2C204D9B00EB5724 /* ShortcutsView.swift */, | ||
6FE1274A2C20943500EB5724 /* ShortcutItemView.swift */, | ||
6F64AA5C2C4920D200CF4489 /* ShortcutAccessoryView.swift */, | ||
6F64AA582C4818D700CF4489 /* NewTabPageShortcut.swift */, | ||
6F64AA5A2C481AAA00CF4489 /* Shortcuts.xcassets */, | ||
6F64AA5E2C49463C00CF4489 /* ShortcutsModel.swift */, | ||
); | ||
name = Shortcuts; | ||
sourceTree = "<group>"; | ||
|
@@ -6328,6 +6340,7 @@ | |
F4F7F10C25813FE200045D62 /* 03_Airstream_divided_by_four.json in Resources */, | ||
AAF2E28723E0498200962AF8 /* [email protected] in Resources */, | ||
AA4D6AB923DE4D15007E8790 /* [email protected] in Resources */, | ||
6F64AA5B2C481AAA00CF4489 /* Shortcuts.xcassets in Resources */, | ||
984147B424F0264B00362052 /* Authentication.storyboard in Resources */, | ||
1EE411FD2858B9300003FE64 /* dark-trackers-2.json in Resources */, | ||
AA4D6ABC23DE4D15007E8790 /* [email protected] in Resources */, | ||
|
@@ -6673,6 +6686,7 @@ | |
6FE095D82BD90AFB00490FF8 /* UniversalOmniBarState.swift in Sources */, | ||
1DEAADE82BA38AA500E25A97 /* SettingsGeneralView.swift in Sources */, | ||
853C5F5B21BFF0AE001F7A05 /* HomeCollectionView.swift in Sources */, | ||
6F64AA592C4818D700CF4489 /* NewTabPageShortcut.swift in Sources */, | ||
3132FA2627A0784600DD7A12 /* FilePreviewHelper.swift in Sources */, | ||
9820FF502244FECC008D4782 /* UIScrollViewExtension.swift in Sources */, | ||
8540BD5423D8D5080057FDD2 /* PreserveLoginsAlert.swift in Sources */, | ||
|
@@ -6898,6 +6912,7 @@ | |
9FB027192C26BC29009EA190 /* BrowsersComparisonModel.swift in Sources */, | ||
3151F0EE2735800800226F58 /* VoiceSearchFeedbackView.swift in Sources */, | ||
37CF91642BB4A82A00BADCAE /* CrashCollectionOnboardingViewModel.swift in Sources */, | ||
6F64AA5D2C4920D200CF4489 /* ShortcutAccessoryView.swift in Sources */, | ||
857EEB752095FFAC008A005C /* HomeRowInstructionsViewController.swift in Sources */, | ||
D63FF8952C1B67E9006DE24D /* YoutubePlayerUserScript.swift in Sources */, | ||
4BF3E4AF2C06A85200ED5D57 /* VPNRedditSessionWorkaround.swift in Sources */, | ||
|
@@ -6991,6 +7006,7 @@ | |
85C861E628FF1B5F00189466 /* HomeViewSectionRenderersExtension.swift in Sources */, | ||
CB825C922C071B1400BCC586 /* AlertView.swift in Sources */, | ||
1DDF40292BA04FCD006850D9 /* SettingsPrivacyProtectionsView.swift in Sources */, | ||
6F64AA5F2C49463C00CF4489 /* ShortcutsModel.swift in Sources */, | ||
F1D477C61F2126CC0031ED49 /* OmniBarState.swift in Sources */, | ||
85F2FFCD2211F615006BB258 /* MainViewController+KeyCommands.swift in Sources */, | ||
6FD3F8192C41252900DA5797 /* NewTabPageControllerDelegate.swift in Sources */, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// NewTabPageShortcut.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 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 UIKit | ||
|
||
enum NewTabPageShortcut: CaseIterable, Equatable, Identifiable, Codable { | ||
var id: String { storageIdentifier } | ||
|
||
case bookmarks, aiChat, passwords, downloads, settings | ||
} | ||
|
||
extension NewTabPageShortcut { | ||
var storageIdentifier: String { | ||
switch self { | ||
case .bookmarks: | ||
"shortcut.storage.identifier.bookmarks" | ||
case .aiChat: | ||
"shortcut.storage.identifier.aichat" | ||
case .passwords: | ||
"shortcut.storage.identifier.passwords" | ||
case .downloads: | ||
"shortcut.storage.identifier.downloads" | ||
case .settings: | ||
"shortcut.storage.identifier.settings" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// ShortcutAccessoryView.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 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 ShortcutAccessoryView: View { | ||
|
||
let accessoryType: ShortcutAccessoryType | ||
|
||
var body: some View { | ||
ZStack { | ||
Circle() | ||
.foregroundStyle(accessoryType.backgroundColor) | ||
Image(accessoryType.iconResource) | ||
.resizable() | ||
.padding(4) | ||
.foregroundColor(accessoryType.foregroundColor) | ||
.aspectRatio(contentMode: .fit) | ||
} | ||
.shadow(color: .shade(0.15), radius: 1, y: 1) | ||
} | ||
} | ||
|
||
enum ShortcutAccessoryType { | ||
case selected | ||
case add | ||
} | ||
|
||
private extension ShortcutAccessoryType { | ||
var iconResource: ImageResource { | ||
switch self { | ||
case .selected: | ||
return .check24 | ||
case .add: | ||
return .add24 | ||
} | ||
} | ||
|
||
var backgroundColor: Color { | ||
switch self { | ||
case .selected: | ||
Color(designSystemColor: .accent) | ||
case .add: | ||
Color(designSystemColor: .surface) | ||
} | ||
} | ||
|
||
var foregroundColor: Color { | ||
switch self { | ||
case .selected: | ||
Color(designSystemColor: .surface) | ||
case .add: | ||
Color(designSystemColor: .accent) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
VStack { | ||
ShortcutAccessoryView(accessoryType: .add).frame(width: 24) | ||
ShortcutAccessoryView(accessoryType: .selected).frame(width: 24) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amddg44 additional source we've discussed. Used here.