Skip to content

Commit 0b1281c

Browse files
committed
Updated icon and fixed animation
1 parent 6b55cb6 commit 0b1281c

File tree

4 files changed

+13
-43
lines changed

4 files changed

+13
-43
lines changed

GoInfoGame/GoInfoGame/Assets.xcassets/upload_sync.imageset/Contents.json

Lines changed: 0 additions & 15 deletions
This file was deleted.
Binary file not shown.

GoInfoGame/GoInfoGame/Helpers/Generated/XCAssets+Generated.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ internal enum Asset {
351351
internal static let noImage = ImageAsset(name: "no_image")
352352
internal static let osmlogo = ImageAsset(name: "osmlogo")
353353
internal static let sync = ImageAsset(name: "sync")
354-
internal static let uploadSync = ImageAsset(name: "upload_sync")
355354
internal static let workspacesLogo = ImageAsset(name: "workspaces_logo")
356355
}
357356
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

GoInfoGame/GoInfoGame/UI/Map/QuestSyncButton.swift

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,24 @@ struct QuestSyncButton: View {
1313
var action: () -> Void
1414

1515
@State private var rotationAngle: Double = 0
16+
@State private var isRotating: Bool = false
1617

1718
var body: some View {
1819
Button(action: action) {
1920
ZStack(alignment: .topTrailing) {
20-
Image("upload_sync")
21-
22-
if isSyncing {
23-
rotatingSyncIcon
24-
.offset(x: 5, y: -5)
25-
.onAppear {
26-
startRotating()
27-
}
28-
.onDisappear {
21+
Image("sync")
22+
.rotationEffect(.degrees(rotationAngle))
23+
.animation(isRotating ? .linear(duration: 1).repeatForever(autoreverses: false) : .default , value: isRotating)
24+
.onChange(of: isSyncing) { newValue in
25+
if newValue {
26+
rotationAngle = 360
27+
isRotating = true
28+
} else {
2929
rotationAngle = 0
30+
isRotating = false
3031
}
31-
} else if badgeCount > 0 {
32+
}
33+
if badgeCount > 0 {
3234
Text("\(badgeCount)")
3335
.font(.caption2)
3436
.padding(5)
@@ -40,22 +42,6 @@ struct QuestSyncButton: View {
4042
}
4143
}
4244
.buttonStyle(.plain)
43-
.onChange(of: isSyncing) { newValue in
44-
if newValue {
45-
startRotating()
46-
} else {
47-
rotationAngle = 0
48-
}
49-
}
50-
}
51-
52-
var rotatingSyncIcon: some View {
53-
Image("sync")
54-
.resizable()
55-
.scaledToFit()
56-
.frame(width: 12, height: 12)
57-
.foregroundStyle(.red)
58-
.rotationEffect(.degrees(rotationAngle), anchor: .center)
5945
}
6046

6147
private func startRotating() {
@@ -67,7 +53,7 @@ struct QuestSyncButton: View {
6753
}
6854

6955
#Preview {
70-
QuestSyncButton(badgeCount: 01, isSyncing: true) {
56+
QuestSyncButton(badgeCount: 0 , isSyncing: true) {
7157

7258
}
7359
.foregroundStyle(Color.green)

0 commit comments

Comments
 (0)