Skip to content

Commit ca97623

Browse files
committed
Optimise the Like button for dark mode and light mode
1 parent 9342c47 commit ca97623

File tree

12 files changed

+52
-134
lines changed

12 files changed

+52
-134
lines changed

Moments/Moments/Assets.xcassets/Colors/card4.colorset/Contents.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

Moments/Moments/Assets.xcassets/Colors/card5.colorset/Contents.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

Moments/Moments/Assets.xcassets/Colors/background1.colorset/Contents.json renamed to Moments/Moments/Assets.xcassets/Colors/likeButtonEnd.colorset/Contents.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"color-space" : "srgb",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "1.000",
9-
"green" : "1.000",
10-
"red" : "1.000"
8+
"blue" : "0.922",
9+
"green" : "0.882",
10+
"red" : "0.882"
1111
}
1212
},
1313
"idiom" : "universal"
@@ -23,9 +23,9 @@
2323
"color-space" : "srgb",
2424
"components" : {
2525
"alpha" : "1.000",
26-
"blue" : "0.000",
27-
"green" : "0.000",
28-
"red" : "0.000"
26+
"blue" : "0.118",
27+
"green" : "0.098",
28+
"red" : "0.098"
2929
}
3030
},
3131
"idiom" : "universal"

Moments/Moments/Assets.xcassets/Colors/card1.colorset/Contents.json renamed to Moments/Moments/Assets.xcassets/Colors/likeButtonFillEnd.colorset/Contents.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"color-space" : "srgb",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "0.988",
9-
"green" : "0.333",
10-
"red" : "0.416"
8+
"blue" : "0.471",
9+
"green" : "0.314",
10+
"red" : "0.118"
1111
}
1212
},
1313
"idiom" : "universal"

Moments/Moments/Assets.xcassets/Colors/card2.colorset/Contents.json renamed to Moments/Moments/Assets.xcassets/Colors/likeButtonFillStart.colorset/Contents.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"color-space" : "srgb",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "0.992",
9-
"green" : "0.745",
10-
"red" : "0.078"
8+
"blue" : "0.941",
9+
"green" : "0.627",
10+
"red" : "0.235"
1111
}
1212
},
1313
"idiom" : "universal"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"colors" : [
3+
{
4+
"color" : {
5+
"color-space" : "srgb",
6+
"components" : {
7+
"alpha" : "1.000",
8+
"blue" : "0.922",
9+
"green" : "0.882",
10+
"red" : "0.882"
11+
}
12+
},
13+
"idiom" : "universal"
14+
}
15+
],
16+
"info" : {
17+
"author" : "xcode",
18+
"version" : 1
19+
}
20+
}

Moments/Moments/Assets.xcassets/Colors/background3.colorset/Contents.json renamed to Moments/Moments/Assets.xcassets/Colors/likeButtonStart.colorset/Contents.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"color-space" : "srgb",
66
"components" : {
77
"alpha" : "1.000",
8-
"blue" : "1.000",
9-
"green" : "1.000",
10-
"red" : "1.000"
8+
"blue" : "0.922",
9+
"green" : "0.882",
10+
"red" : "0.882"
1111
}
1212
},
1313
"idiom" : "universal"
@@ -23,9 +23,9 @@
2323
"color-space" : "srgb",
2424
"components" : {
2525
"alpha" : "1.000",
26-
"blue" : "0.133",
27-
"green" : "0.133",
28-
"red" : "0.133"
26+
"blue" : "0.255",
27+
"green" : "0.235",
28+
"red" : "0.196"
2929
}
3030
},
3131
"idiom" : "universal"

Moments/Moments/Features/Moments-SwiftUI/Views/SwiftUIMomentListItemView.swift

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,55 +15,29 @@ private struct IdentifiableURL: Identifiable {
1515
var id = UUID()
1616
}
1717

18-
extension Color {
19-
static let offWhite = Color(red: 225 / 255, green: 225 / 255, blue: 235 / 255)
20-
21-
static let darkStart = Color(red: 50 / 255, green: 60 / 255, blue: 65 / 255)
22-
static let darkEnd = Color(red: 25 / 255, green: 25 / 255, blue: 30 / 255)
23-
24-
static let lightStart = Color(red: 60 / 255, green: 160 / 255, blue: 240 / 255)
25-
static let lightEnd = Color(red: 30 / 255, green: 80 / 255, blue: 120 / 255)
26-
}
27-
2818
struct LikeToggleBackground<S: Shape>: View {
2919
var isHighlighted: Bool
3020
var shape: S
3121

22+
//swiftlint:disable no_hardcoded_strings
3223
var body: some View {
3324
ZStack {
3425
if isHighlighted {
3526
shape
36-
.fill(LinearGradient(Color.lightEnd, Color.lightStart))
37-
.overlay(shape.stroke(LinearGradient(Color.lightStart, Color.lightEnd), lineWidth: 2))
38-
.shadow(color: Color.darkStart, radius: 5, x: 5, y: 5)
39-
.shadow(color: Color.darkEnd, radius: 5, x: -5, y: -5)
40-
// .fill(Color.offWhite)
41-
// .overlay(
42-
// Circle()
43-
// .stroke(Color.gray, lineWidth: 4)
44-
// .blur(radius: 4)
45-
// .offset(x: 2, y: 2)
46-
// .mask(Circle().fill(LinearGradient(Color.black, Color.clear)))
47-
// )
48-
// .overlay(
49-
// Circle()
50-
// .stroke(Color.white, lineWidth: 8)
51-
// .blur(radius: 4)
52-
// .offset(x: -2, y: -2)
53-
// .mask(Circle().fill(LinearGradient(Color.clear, Color.black)))
54-
// )
27+
.fill(LinearGradient(Color("likeButtonFillEnd"), Color("likeButtonFillStart")))
28+
.overlay(shape.stroke(LinearGradient(Color("likeButtonFillStart"), Color("likeButtonFillEnd")), lineWidth: 2))
29+
.shadow(color: Color("likeButtonStart"), radius: 5, x: 5, y: 5)
30+
.shadow(color: Color("likeButtonEnd"), radius: 5, x: -5, y: -5)
5531
} else {
5632
shape
57-
.fill(LinearGradient(Color.darkStart, Color.darkEnd))
58-
.overlay(shape.stroke(LinearGradient(Color.lightStart, Color.lightEnd), lineWidth: 2))
59-
.shadow(color: Color.darkStart, radius: 5, x: 5, y: 5)
60-
.shadow(color: Color.darkEnd, radius: 5, x: -5, y: -5)
61-
// .fill(Color.offWhite)
62-
// .shadow(color: Color.black.opacity(0.2), radius: 10, x: 10, y: 10)
63-
// .shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)
33+
.fill(LinearGradient(Color("likeButtonFillStart"), Color("likeButtonFillEnd")))
34+
.overlay(shape.stroke(LinearGradient(Color("likeButtonFillStart"), Color("likeButtonFillEnd")), lineWidth: 2))
35+
.shadow(color: Color("likeButtonStart"), radius: 5, x: 5, y: 5)
36+
.shadow(color: Color("likeButtonEnd"), radius: 5, x: -5, y: -5)
6437
}
6538
}
6639
}
40+
//swiftlint:enable no_hardcoded_strings
6741
}
6842

6943
struct LikeToggleStyle: ToggleStyle {
@@ -72,7 +46,7 @@ struct LikeToggleStyle: ToggleStyle {
7246
configuration.isOn.toggle()
7347
}, label: {
7448
configuration.label
75-
.padding(8)
49+
.padding(Spacing.extraSmall)
7650
.contentShape(Circle())
7751
})
7852
.background(
@@ -144,7 +118,7 @@ struct SwiftUIMomentListItemView: View {
144118
Toggle(isOn: $isLiked) {
145119
//swiftlint:disable no_hardcoded_strings
146120
Image(systemName: "heart.fill")
147-
.foregroundColor(isLiked == true ? .red : .white)
121+
.foregroundColor(isLiked == true ? Color("likeButtonSelected") : Color("likeButtonNotSelected"))
148122
.animation(.easeIn)
149123
//swiftlint:enable no_hardcoded_strings
150124
}

0 commit comments

Comments
 (0)