@@ -10,7 +10,8 @@ import SwiftUI
10
10
struct CommitListItemView : View {
11
11
12
12
var commit : GitCommit
13
- var width : CGFloat ?
13
+ var showRef : Bool
14
+ var width : CGFloat
14
15
15
16
private var defaultAvatar : some View {
16
17
Image ( systemName: " person.crop.circle.fill " )
@@ -47,70 +48,80 @@ struct CommitListItemView: View {
47
48
@Environment ( \. openURL)
48
49
private var openCommit
49
50
50
- init ( commit: GitCommit ) {
51
+ init ( commit: GitCommit , showRef : Bool ) {
51
52
self . commit = commit
52
- //self.width = width
53
- //print("CGFloat", width)
53
+ self . showRef = showRef
54
+ self . width = 0
55
+ }
56
+
57
+ init ( commit: GitCommit , showRef: Bool , width: CGFloat ) {
58
+ self . commit = commit
59
+ self . showRef = showRef
60
+ self . width = width
54
61
}
55
62
56
63
var body : some View {
57
64
HStack ( alignment: . top) {
58
- AsyncImage ( url: URL ( string: " https://www.gravatar.com/avatar/ \( generateAvatarHash ( ) ) " ) ) { phase in
59
- if let image = phase. image {
60
- image
61
- . resizable ( )
62
- . clipShape ( Circle ( ) )
63
- . frame ( width: 32 , height: 32 )
64
- . help ( commit. author)
65
- } else if phase. error != nil {
66
- defaultAvatar
67
- . help ( commit. author)
68
- } else {
69
- defaultAvatar
70
- . help ( commit. author)
65
+ if width > 360 {
66
+ AsyncImage ( url: URL ( string: " https://www.gravatar.com/avatar/ \( generateAvatarHash ( ) ) " ) ) { phase in
67
+ if let image = phase. image {
68
+ image
69
+ . resizable ( )
70
+ . clipShape ( Circle ( ) )
71
+ . frame ( width: 32 , height: 32 )
72
+ . help ( commit. author)
73
+ } else if phase. error != nil {
74
+ defaultAvatar
75
+ . help ( commit. author)
76
+ } else {
77
+ defaultAvatar
78
+ . help ( commit. author)
79
+ }
71
80
}
72
81
}
73
82
VStack ( alignment: . leading, spacing: 0 ) {
74
83
HStack {
75
84
Text ( commit. author)
76
85
. fontWeight ( . bold)
77
86
. font ( . system( size: 11 ) )
78
- if !commit. refs. isEmpty {
79
- HStack {
80
- ForEach ( commit. refs, id: \. self) { ref in
81
- HStack {
82
- Image . branch
83
- . imageScale ( . small)
84
- . foregroundColor ( . primary)
85
- Text ( ref)
86
- . font ( . system( size: 10 , design: . monospaced) )
87
+ if showRef {
88
+ if !commit. refs. isEmpty {
89
+ HStack {
90
+ ForEach ( commit. refs, id: \. self) { ref in
91
+ HStack {
92
+ Image . branch
93
+ . imageScale ( . small)
94
+ . foregroundColor ( . primary)
95
+ Text ( ref)
96
+ . font ( . system( size: 10 , design: . monospaced) )
97
+ }
98
+ . background (
99
+ RoundedRectangle ( cornerRadius: 3 )
100
+ . padding ( . vertical, - 1 )
101
+ . padding ( . horizontal, - 2.5 )
102
+ . foregroundColor ( Color ( nsColor: . quaternaryLabelColor) )
103
+ )
104
+ . padding ( . trailing, 2.5 )
87
105
}
88
- . background (
89
- RoundedRectangle ( cornerRadius: 3 )
90
- . padding ( . vertical, - 1 )
91
- . padding ( . horizontal, - 2.5 )
92
- . foregroundColor ( Color ( nsColor: . quaternaryLabelColor) )
93
- )
94
- . padding ( . trailing, 2.5 )
95
106
}
96
107
}
97
- }
98
-
99
- if !commit. tag. isEmpty {
100
- HStack {
101
- Image . breakpoint
102
- . imageScale ( . small)
103
- . foregroundColor ( . primary)
104
- Text ( commit. tag)
105
- . font ( . system( size: 10 , design: . monospaced) )
108
+
109
+ if !commit. tag. isEmpty {
110
+ HStack {
111
+ Image . breakpoint
112
+ . imageScale ( . small)
113
+ . foregroundColor ( . primary)
114
+ Text ( commit. tag)
115
+ . font ( . system( size: 10 , design: . monospaced) )
116
+ }
117
+ . background (
118
+ RoundedRectangle ( cornerRadius: 3 )
119
+ . padding ( . vertical, - 1 )
120
+ . padding ( . horizontal, - 2.5 )
121
+ . foregroundColor ( Color ( nsColor: . selectedContentBackgroundColor) )
122
+ )
123
+ . padding ( . trailing, 2.5 )
106
124
}
107
- . background (
108
- RoundedRectangle ( cornerRadius: 3 )
109
- . padding ( . vertical, - 1 )
110
- . padding ( . horizontal, - 2.5 )
111
- . foregroundColor ( Color ( nsColor: . selectedContentBackgroundColor) )
112
- )
113
- . padding ( . trailing, 2.5 )
114
125
}
115
126
}
116
127
0 commit comments