@@ -17,48 +17,35 @@ struct TaskNotificationView: View {
17
17
18
18
var body : some View {
19
19
ZStack {
20
- if let notification {
21
- HStack {
22
- Text ( notification. title)
23
- . font ( . subheadline)
24
- . transition (
25
- . asymmetric( insertion: . move( edge: . top) , removal: . move( edge: . bottom) )
26
- . combined ( with: . opacity)
27
- )
28
- . id ( " NotificationTitle " + notification. title)
29
-
30
- if notification. isLoading {
31
- CECircularProgressView (
32
- progress: notification. percentage,
33
- currentTaskCount: taskNotificationHandler. notifications. count
34
- )
35
- . padding ( . horizontal, - 1 )
36
- . frame ( height: 16 )
37
- } else {
38
- if taskNotificationHandler. notifications. count > 1 {
39
- Text ( " \( taskNotificationHandler. notifications. count) " )
40
- . font ( . caption)
41
- . padding ( 5 )
42
- . background (
43
- Circle ( )
44
- . foregroundStyle ( . gray)
45
- . opacity ( 0.2 )
46
- )
47
- . padding ( - 5 )
48
- }
20
+ HStack {
21
+ if let notification {
22
+ HStack {
23
+ Text ( notification. title)
24
+ . font ( . subheadline)
25
+ . transition (
26
+ . asymmetric( insertion: . move( edge: . top) , removal: . move( edge: . bottom) )
27
+ . combined ( with: . opacity)
28
+ )
29
+ . id ( " NotificationTitle " + notification. title)
49
30
}
31
+ . transition ( . opacity. combined ( with: . move( edge: . trailing) ) )
32
+
33
+ loaderView ( notification: notification)
34
+ . transition ( . opacity)
35
+ . id ( " Loader " )
36
+ } else {
37
+ Text ( " " )
38
+ . id ( " Loader " )
50
39
}
51
- . transition ( . opacity. combined ( with: . move( edge: . trailing) ) )
52
- . opacity ( activeState == . inactive ? 0.4 : 1.0 )
53
- . padding ( 3 )
54
- . padding ( - 3 )
55
- . padding ( . trailing, 3 )
56
- . popover ( isPresented: $isPresented, arrowEdge: . bottom) {
57
- TaskNotificationsDetailView ( taskNotificationHandler: taskNotificationHandler)
58
- }
59
- . onTapGesture {
60
- self . isPresented. toggle ( )
61
- }
40
+ }
41
+ . opacity ( activeState == . inactive ? 0.4 : 1.0 )
42
+ . padding ( 3 )
43
+ . padding ( - 3 )
44
+ . popover ( isPresented: $isPresented, arrowEdge: . bottom) {
45
+ TaskNotificationsDetailView ( taskNotificationHandler: taskNotificationHandler)
46
+ }
47
+ . onTapGesture {
48
+ self . isPresented. toggle ( )
62
49
}
63
50
}
64
51
. animation ( . easeInOut, value: notification)
@@ -69,6 +56,29 @@ struct TaskNotificationView: View {
69
56
}
70
57
}
71
58
59
+ @ViewBuilder
60
+ private func loaderView( notification: TaskNotificationModel ) -> some View {
61
+ if notification. isLoading {
62
+ CECircularProgressView (
63
+ progress: notification. percentage,
64
+ currentTaskCount: taskNotificationHandler. notifications. count
65
+ )
66
+ . padding ( . horizontal, - 1 )
67
+ . frame ( height: 16 )
68
+ } else {
69
+ if taskNotificationHandler. notifications. count > 1 {
70
+ Text ( " \( taskNotificationHandler. notifications. count) " )
71
+ . font ( . caption)
72
+ . padding ( 5 )
73
+ . background (
74
+ Circle ( )
75
+ . foregroundStyle ( . gray)
76
+ . opacity ( 0.2 )
77
+ )
78
+ . padding ( - 5 )
79
+ }
80
+ }
81
+ }
72
82
}
73
83
74
84
#Preview {
0 commit comments