Skip to content

Commit 32c6270

Browse files
AppTP design review (duckduckgo#1748)
Co-authored-by: Sam Symons <[email protected]>
1 parent bdb3aef commit 32c6270

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+589
-108
lines changed

Core/AppTrackingProtectionListViewModel.swift

+4-22
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,8 @@ public class AppTrackingProtectionListViewModel: NSObject, ObservableObject, NSF
2929
case historyTransactionConversionFailed
3030
}
3131

32-
public enum TrackerSorting {
33-
case count
34-
case timestamp
35-
}
36-
3732
@Published public var sections: [NSFetchedResultsSectionInfo] = []
3833

39-
@Published public var trackerSortingOption: TrackerSorting = .count {
40-
didSet {
41-
setupFetchedResultsController()
42-
}
43-
}
44-
4534
@Published public var debugModeEnabled = false
4635

4736
// We only want to show "Manage Trackers" and "Report an issue" if the user has enabled AppTP at least once
@@ -120,20 +109,13 @@ public class AppTrackingProtectionListViewModel: NSObject, ObservableObject, NSF
120109

121110
fileprivate var fetchedResultsController: NSFetchedResultsController<AppTrackerEntity>!
122111

123-
private func createFetchedResultsController(sortedBy sortingOption: TrackerSorting) -> NSFetchedResultsController<AppTrackerEntity> {
112+
private func createFetchedResultsController() -> NSFetchedResultsController<AppTrackerEntity> {
124113
let fetchRequest: NSFetchRequest<AppTrackerEntity> = AppTrackerEntity.fetchRequest()
125114

126115
let bucketSortDescriptor = NSSortDescriptor(key: #keyPath(AppTrackerEntity.bucket), ascending: false)
127116
let domainSortDescriptor = NSSortDescriptor(key: #keyPath(AppTrackerEntity.domain), ascending: true)
128-
129-
switch sortingOption {
130-
case .count:
131-
let countSortDescriptor = NSSortDescriptor(key: #keyPath(AppTrackerEntity.count), ascending: false)
132-
fetchRequest.sortDescriptors = [bucketSortDescriptor, countSortDescriptor, domainSortDescriptor]
133-
case .timestamp:
134-
let timestampSortDescriptor = NSSortDescriptor(key: #keyPath(AppTrackerEntity.timestamp), ascending: false)
135-
fetchRequest.sortDescriptors = [bucketSortDescriptor, timestampSortDescriptor, domainSortDescriptor]
136-
}
117+
let timestampSortDescriptor = NSSortDescriptor(key: #keyPath(AppTrackerEntity.timestamp), ascending: false)
118+
fetchRequest.sortDescriptors = [bucketSortDescriptor, timestampSortDescriptor, domainSortDescriptor]
137119

138120
let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest,
139121
managedObjectContext: self.context,
@@ -158,7 +140,7 @@ public class AppTrackingProtectionListViewModel: NSObject, ObservableObject, NSF
158140
}
159141

160142
private func setupFetchedResultsController() {
161-
self.fetchedResultsController = createFetchedResultsController(sortedBy: self.trackerSortingOption)
143+
self.fetchedResultsController = createFetchedResultsController()
162144

163145
self.fetchedResultsController.delegate = self
164146
try? self.fetchedResultsController.performFetch()

DuckDuckGo.xcodeproj/project.pbxproj

+12-12
Original file line numberDiff line numberDiff line change
@@ -835,19 +835,19 @@
835835
/* End PBXBuildFile section */
836836

837837
/* Begin PBXContainerItemProxy section */
838-
0202566A298818B200E694E7 /* PBXContainerItemProxy */ = {
838+
025CCFE72582601C001CD5BB /* PBXContainerItemProxy */ = {
839839
isa = PBXContainerItemProxy;
840840
containerPortal = 84E3418A1E2F7EFB00BDBA6F /* Project object */;
841841
proxyType = 1;
842-
remoteGlobalIDString = 02025661298818B100E694E7;
843-
remoteInfo = PacketTunnelProvider;
842+
remoteGlobalIDString = 84E341911E2F7EFB00BDBA6F;
843+
remoteInfo = DuckDuckGo;
844844
};
845-
025CCFE72582601C001CD5BB /* PBXContainerItemProxy */ = {
845+
02FFD7BB2A1FC8BE007BD7D1 /* PBXContainerItemProxy */ = {
846846
isa = PBXContainerItemProxy;
847847
containerPortal = 84E3418A1E2F7EFB00BDBA6F /* Project object */;
848848
proxyType = 1;
849-
remoteGlobalIDString = 84E341911E2F7EFB00BDBA6F;
850-
remoteInfo = DuckDuckGo;
849+
remoteGlobalIDString = 02025661298818B100E694E7;
850+
remoteInfo = PacketTunnelProvider;
851851
};
852852
4B470EE6299C6DFB0086EBDC /* PBXContainerItemProxy */ = {
853853
isa = PBXContainerItemProxy;
@@ -5029,7 +5029,7 @@
50295029
8390447520BDCE10006461CD /* PBXTargetDependency */,
50305030
85482D932462DCD100EDEDD1 /* PBXTargetDependency */,
50315031
8512EA5C24ED30D30073EE19 /* PBXTargetDependency */,
5032-
0202566B298818B200E694E7 /* PBXTargetDependency */,
5032+
02FFD7BC2A1FC8BE007BD7D1 /* PBXTargetDependency */,
50335033
);
50345034
name = DuckDuckGo;
50355035
packageProductDependencies = (
@@ -6416,16 +6416,16 @@
64166416
/* End PBXSourcesBuildPhase section */
64176417

64186418
/* Begin PBXTargetDependency section */
6419-
0202566B298818B200E694E7 /* PBXTargetDependency */ = {
6420-
isa = PBXTargetDependency;
6421-
target = 02025661298818B100E694E7 /* PacketTunnelProvider */;
6422-
targetProxy = 0202566A298818B200E694E7 /* PBXContainerItemProxy */;
6423-
};
64246419
025CCFE82582601C001CD5BB /* PBXTargetDependency */ = {
64256420
isa = PBXTargetDependency;
64266421
target = 84E341911E2F7EFB00BDBA6F /* DuckDuckGo */;
64276422
targetProxy = 025CCFE72582601C001CD5BB /* PBXContainerItemProxy */;
64286423
};
6424+
02FFD7BC2A1FC8BE007BD7D1 /* PBXTargetDependency */ = {
6425+
isa = PBXTargetDependency;
6426+
target = 02025661298818B100E694E7 /* PacketTunnelProvider */;
6427+
targetProxy = 02FFD7BB2A1FC8BE007BD7D1 /* PBXContainerItemProxy */;
6428+
};
64296429
4B470EE7299C6DFB0086EBDC /* PBXTargetDependency */ = {
64306430
isa = PBXTargetDependency;
64316431
target = F143C2E31E4A4CD400CFDE3A /* Core */;

DuckDuckGo/AppTP.xcassets/Colors/AppTPBreakageButtonLabelDisabled.colorset/Contents.json

+22-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,28 @@
44
"color" : {
55
"color-space" : "srgb",
66
"components" : {
7-
"alpha" : "0.360",
8-
"blue" : "0xFF",
9-
"green" : "0xFF",
10-
"red" : "0xFF"
7+
"alpha" : "1.000",
8+
"blue" : "0x93",
9+
"green" : "0x93",
10+
"red" : "0x93"
11+
}
12+
},
13+
"idiom" : "universal"
14+
},
15+
{
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"color-space" : "srgb",
24+
"components" : {
25+
"alpha" : "1.000",
26+
"blue" : "0x8B",
27+
"green" : "0x8B",
28+
"red" : "0x8B"
1129
}
1230
},
1331
"idiom" : "universal"

DuckDuckGo/AppTP.xcassets/Colors/AppTPDomainColor.colorset/Contents.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"color" : {
55
"color-space" : "srgb",
66
"components" : {
7-
"alpha" : "1.000",
7+
"alpha" : "0.840",
88
"blue" : "0.000",
99
"green" : "0.000",
1010
"red" : "0.000"
@@ -22,7 +22,7 @@
2222
"color" : {
2323
"color-space" : "srgb",
2424
"components" : {
25-
"alpha" : "1.000",
25+
"alpha" : "0.840",
2626
"blue" : "1.000",
2727
"green" : "1.000",
2828
"red" : "1.000"

DuckDuckGo/AppTPActivityView.swift

+25-18
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ struct AppTPActivityView: View {
5656

5757
var listState: some View {
5858
VStack {
59-
Picker("Tracker Sorting", selection: $viewModel.trackerSortingOption) {
60-
Text("Sort By Count").tag(AppTrackingProtectionListViewModel.TrackerSorting.count)
61-
Text("Sort By Date").tag(AppTrackingProtectionListViewModel.TrackerSorting.timestamp)
62-
}
63-
.pickerStyle(.segmented)
64-
6559
ForEach(viewModel.sections, id: \.name) { section in
6660
Section(content: {
6761
LazyVStack(alignment: .leading, spacing: 0) {
@@ -89,7 +83,7 @@ struct AppTPActivityView: View {
8983
.cornerRadius(Const.Size.cornerRadius)
9084
}, header: {
9185
HStack {
92-
Text(viewModel.formattedDate(section.name))
86+
Text(viewModel.formattedDate(section.name).uppercased())
9387
.font(Font(uiFont: Const.Font.sectionHeader))
9488
.foregroundColor(.infoText)
9589
.padding(.top)
@@ -100,18 +94,14 @@ struct AppTPActivityView: View {
10094
}
10195
})
10296
}
103-
104-
Toggle(isOn: $viewModel.debugModeEnabled, label: {
105-
Text("Show Additional Tracker Information")
106-
})
107-
.padding(.top, 8)
10897
}
10998
}
11099

111100
var manageSection: some View {
112101
Section {
113102
VStack(alignment: .leading, spacing: 0) {
114103
NavigationLink(destination: AppTPManageTrackersView(viewModel: AppTPManageTrackersViewModel(),
104+
feedbackModel: feedbackModel,
115105
imageCache: imageCache)) {
116106
HStack {
117107
Text(UserText.appTPManageTrackers)
@@ -125,6 +115,7 @@ struct AppTPActivityView: View {
125115
}
126116

127117
Divider()
118+
.padding(.leading)
128119

129120
NavigationLink(destination: AppTPBreakageFormView(feedbackModel: feedbackModel)) {
130121
HStack {
@@ -144,7 +135,7 @@ struct AppTPActivityView: View {
144135
}
145136
}
146137

147-
var body: some View {
138+
var scrollView: some View {
148139
ScrollView {
149140
LazyVStack(alignment: .center, spacing: 0) {
150141
Section {
@@ -174,27 +165,43 @@ struct AppTPActivityView: View {
174165
.background(Color.viewBackground)
175166
.navigationTitle(UserText.appTPNavTitle)
176167
}
168+
169+
@ViewBuilder
170+
var scrollWithBackgroud: some View {
171+
if #available(iOS 16, *) {
172+
scrollView
173+
.scrollContentBackground(.hidden)
174+
.background(Color.viewBackground)
175+
} else {
176+
scrollView
177+
.background(Color.viewBackground)
178+
}
179+
}
180+
181+
var body: some View {
182+
scrollWithBackgroud
183+
}
177184
}
178185

179186
private enum Const {
180187
enum Font {
181-
static let sectionHeader = UIFont.semiBoldAppFont(ofSize: 15)
188+
static let sectionHeader = UIFont.systemFont(ofSize: 12)
182189
static let info = UIFont.appFont(ofSize: 16)
183190
}
184191

185192
enum Size {
186193
static let cornerRadius: CGFloat = 12
187194
static let sectionIndentation: CGFloat = 16
188-
static let sectionHeaderBottom: CGFloat = 6
195+
static let sectionHeaderBottom: CGFloat = -2
189196
static let standardCellHeight: CGFloat = 44
190197
}
191198
}
192199

193200
private extension Color {
194201
static let infoText = Color("AppTPDomainColor")
195-
static let buttonColor = Color("AppTPToggleColor")
196-
static let cellBackground = Color("AppTPCellBackgroundColor")
197-
static let viewBackground = Color("AppTPViewBackgroundColor")
202+
static let buttonColor = Color(designSystemColor: .accent)
203+
static let cellBackground = Color(designSystemColor: .surface)
204+
static let viewBackground = Color(designSystemColor: .background)
198205
}
199206

200207
#endif

DuckDuckGo/AppTPBreakageFormView.swift

+28-8
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,24 @@ struct AppTPBreakageFormView: View {
8686
}
8787

8888
var body: some View {
89+
formWithBackground
90+
}
91+
92+
@ViewBuilder
93+
var formWithBackground: some View {
94+
if #available(iOS 16.0, *) {
95+
form
96+
.scrollContentBackground(.hidden)
97+
.background(Color.viewBackground)
98+
} else {
99+
form
100+
.background(Color.viewBackground)
101+
}
102+
}
103+
104+
var form: some View {
89105
ZStack {
90-
Form {
106+
List {
91107
Section {
92108
VStack {
93109
AppTPBreakageFormHeaderView(text: UserText.appTPReportAppLabel)
@@ -126,23 +142,22 @@ struct AppTPBreakageFormView: View {
126142
if self.description.isEmpty {
127143
TextEditor(text: $placeholderText)
128144
.font(.body)
129-
.foregroundColor(.gray)
145+
.foregroundColor(Color(UIColor.placeholderText))
130146
.disabled(true)
131147
}
132148

133149
TextEditor(text: $description)
134150
.font(.body)
135-
.opacity(self.description.isEmpty ? 0.25 : 1)
136151
}
137152
.padding(.leading, Const.Size.commentFieldPadding)
138153
}
139154
.frame(minHeight: Const.Size.minCommentHeight)
140155
} footer: {
141156
Text(UserText.appTPReportFooter)
142-
.fontWithLineHeight(font: Const.Font.footer, lineHeight: Const.Size.lineHeight)
143-
.foregroundColor(.infoText)
144-
.padding(.leading, Const.Size.sectionIndentation)
145-
.padding(.top)
157+
.fontWithLineHeight(font: Const.Font.footer, lineHeight: Const.Size.lineHeight)
158+
.foregroundColor(.footerText)
159+
.padding(.leading, Const.Size.sectionIndentation)
160+
.padding(.top)
146161
}
147162

148163
Section {
@@ -154,10 +169,13 @@ struct AppTPBreakageFormView: View {
154169
.frame(maxWidth: .infinity, alignment: .center)
155170
.foregroundColor(appName.isEmpty ? Color.disabledButtonLabel : Color.buttonLabelColor)
156171
})
172+
.buttonStyle(PlainButtonStyle())
173+
.frame(height: 30)
157174
.listRowBackground(appName.isEmpty ? Color.disabledButton : Color.buttonColor)
158175
.disabled(appName.isEmpty)
159176
}
160177
}
178+
.listStyle(.insetGrouped)
161179
.navigationTitle(UserText.appTPReportTitle)
162180
.alert(isPresented: $showError) {
163181
Alert(
@@ -188,8 +206,10 @@ private enum Const {
188206

189207
private extension Color {
190208
static let infoText = Color("AppTPDomainColor")
191-
static let buttonColor = Color("AppTPBreakageButton")
209+
static let footerText = Color(designSystemColor: .textSecondary)
210+
static let buttonColor = Color(designSystemColor: .accent)
192211
static let buttonLabelColor = Color("AppTPBreakageButtonLabel")
193212
static let disabledButton = Color("AppTPBreakageButtonDisabled")
194213
static let disabledButtonLabel = Color("AppTPBreakageButtonLabelDisabled")
214+
static let viewBackground = Color(designSystemColor: .background)
195215
}

0 commit comments

Comments
 (0)