Skip to content

Commit f49169b

Browse files
committed
Major UI Updates
- Changed mesh to true by default - Add thinMaterial Presentation Background - Improved alignment
1 parent 65c66a1 commit f49169b

File tree

1 file changed

+78
-37
lines changed

1 file changed

+78
-37
lines changed

Sources/SwiftNEW/SwiftNEW.swift

Lines changed: 78 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public struct SwiftNEW: View {
4343
history: Binding<Bool>? = .constant(true),
4444
data: Binding<String>? = .constant("data"),
4545
showDrop: Binding<Bool>? = .constant(false),
46-
mesh: Binding<Bool>? = .constant(false),
46+
mesh: Binding<Bool>? = .constant(true),
4747
specialEffect: Binding<String>? = .constant("")
4848
) {
4949
_show = show
@@ -56,7 +56,7 @@ public struct SwiftNEW: View {
5656
_history = history ?? .constant(true)
5757
_data = data ?? .constant("data")
5858
_showDrop = showDrop ?? .constant(false)
59-
_mesh = mesh ?? .constant(false)
59+
_mesh = mesh ?? .constant(true)
6060
_specialEffect = specialEffect ?? .constant("")
6161
compareVersion()
6262
}
@@ -72,7 +72,7 @@ public struct SwiftNEW: View {
7272
history: Binding<Bool>? = .constant(true),
7373
data: Binding<String>? = .constant("data"),
7474
showDrop: Binding<Bool>? = .constant(false),
75-
mesh: Binding<Bool>? = .constant(false),
75+
mesh: Binding<Bool>? = .constant(true),
7676
specialEffect: Binding<String>? = .constant("")
7777
) {
7878
_show = show
@@ -85,7 +85,7 @@ public struct SwiftNEW: View {
8585
_history = history ?? .constant(true)
8686
_data = data ?? .constant("data")
8787
_showDrop = showDrop ?? .constant(false)
88-
_mesh = mesh ?? .constant(false)
88+
_mesh = mesh ?? .constant(true)
8989
_specialEffect = specialEffect ?? .constant("")
9090
compareVersion()
9191
}
@@ -125,7 +125,12 @@ public struct SwiftNEW: View {
125125
}
126126
sheetCurrent
127127
.sheet(isPresented: $historySheet) {
128-
sheetHistory
128+
if #available(iOS 16.4, *) {
129+
sheetHistory
130+
.presentationBackground(.thinMaterial)
131+
} else {
132+
sheetHistory
133+
}
129134
}
130135
#if os(xrOS)
131136
.padding()
@@ -157,34 +162,51 @@ public struct SwiftNEW: View {
157162
if item.version == Bundle.version || item.subVersion == Bundle.version {
158163
ForEach(item.new, id: \.self) { new in
159164
HStack {
160-
ZStack {
161-
color
162-
Image(systemName: new.icon)
163-
.foregroundColor(.white)
165+
if align == .leading || align == .center {
166+
ZStack {
167+
color
168+
Image(systemName: new.icon)
169+
.foregroundColor(.white)
170+
}
171+
.frame(width: 50, height:50)
172+
.cornerRadius(15)
173+
.padding(.trailing)
174+
} else {
175+
Spacer()
164176
}
165-
.frame(width: 50, height:50)
166-
.cornerRadius(15)
167-
.padding(.trailing)
168-
VStack(alignment: .leading) {
177+
178+
VStack(alignment: align == .trailing ? .trailing : .leading) {
169179
Text(new.title).font(.headline).lineLimit(1)
170180
Text(new.subtitle).font(.subheadline).foregroundColor(.secondary).lineLimit(1)
171181
Text(new.body).font(.caption).foregroundColor(.secondary).lineLimit(2)
172182
}
173-
Spacer()
183+
184+
if align == .trailing {
185+
ZStack {
186+
color
187+
Image(systemName: new.icon)
188+
.foregroundColor(.white)
189+
}
190+
.frame(width: 50, height:50)
191+
.cornerRadius(15)
192+
.padding(.trailing)
193+
} else {
194+
Spacer()
195+
}
174196
}.padding(.bottom)
175197
}
176198
}
177199
}
200+
if history {
201+
showHistoryButton
202+
}
178203
}.frame(width: 300)
179-
.frame(maxHeight: 450)
204+
// .frame(maxHeight: 450)
205+
.frame(maxHeight: UIScreen.main.bounds.height * 0.5)
180206
}
181207

182208
Spacer()
183209

184-
if history {
185-
showHistoryButton
186-
}
187-
188210
closeCurrentButton
189211
.padding(.bottom)
190212
}
@@ -229,7 +251,9 @@ public struct SwiftNEW: View {
229251
}
230252
#endif
231253
public var showHistoryButton: some View {
232-
Button(action: { historySheet = true }) {
254+
Button(action: {
255+
historySheet = true
256+
}) {
233257
HStack {
234258
if align == .trailing {
235259
Spacer()
@@ -239,15 +263,12 @@ public struct SwiftNEW: View {
239263
if align == .leading {
240264
Spacer()
241265
}
242-
}.font(.body)
243-
#if os(iOS)
244-
.frame(width: 300, height: 50)
245-
#elseif os(macOS)
246-
.frame(width: 200, height: 25)
247-
#endif
266+
}.font(.caption)
248267
}
249268
#if !os(xrOS)
250-
.foregroundColor(color)
269+
.buttonStyle(.bordered)
270+
.buttonBorderShape(.capsule)
271+
.tint(.secondary)
251272
#endif
252273
}
253274
public var closeCurrentButton: some View {
@@ -263,6 +284,7 @@ public struct SwiftNEW: View {
263284
Spacer()
264285
}
265286
}.font(.body)
287+
.padding(.horizontal)
266288
#if os(iOS)
267289
.frame(width: 300, height: 50)
268290
#elseif os(macOS)
@@ -296,25 +318,43 @@ public struct SwiftNEW: View {
296318
.padding(.bottom)
297319
ForEach(item.new, id: \.self) { new in
298320
HStack {
299-
ZStack {
300-
color
301-
Image(systemName: new.icon)
302-
.foregroundColor(.white)
321+
if align == .leading || align == .center {
322+
ZStack {
323+
color
324+
Image(systemName: new.icon)
325+
.foregroundColor(.white)
326+
}
327+
.frame(width: 50, height:50)
328+
.cornerRadius(15)
329+
.padding(.trailing)
330+
} else {
331+
Spacer()
303332
}
304-
.frame(width: 50, height:50)
305-
.cornerRadius(15)
306-
.padding(.trailing)
307-
VStack(alignment: .leading) {
333+
334+
VStack(alignment: align == .trailing ? .trailing : .leading) {
308335
Text(new.title).font(.headline).lineLimit(1)
309336
Text(new.subtitle).font(.subheadline).foregroundColor(.secondary).lineLimit(1)
310337
Text(new.body).font(.caption).foregroundColor(.secondary).lineLimit(2)
311338
}
312-
Spacer()
339+
340+
if align == .trailing {
341+
ZStack {
342+
color
343+
Image(systemName: new.icon)
344+
.foregroundColor(.white)
345+
}
346+
.frame(width: 50, height:50)
347+
.cornerRadius(15)
348+
.padding(.leading)
349+
} else {
350+
Spacer()
351+
}
313352
}.padding(.bottom)
314353
}
315354
}
316355
}.frame(width: 300)
317-
.frame(maxHeight: 450)
356+
// .frame(maxHeight: 450)
357+
.frame(maxHeight: UIScreen.main.bounds.height * 0.6)
318358

319359
Spacer()
320360

@@ -339,6 +379,7 @@ public struct SwiftNEW: View {
339379
Spacer()
340380
}
341381
}.font(.body)
382+
.padding(.horizontal)
342383
#if os(iOS)
343384
.frame(width: 300, height: 50)
344385
#elseif os(macOS)

0 commit comments

Comments
 (0)