Skip to content

Commit 85ebac8

Browse files
committed
Add New Examples: List and Buttons
1 parent 80b52e9 commit 85ebac8

File tree

11 files changed

+415
-162
lines changed

11 files changed

+415
-162
lines changed

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,14 @@
7777
3A80CEF82DB4C1D9006BDD0A /* Exceptions for "Demo" folder in "Watch Watch App" target */ = {
7878
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
7979
membershipExceptions = (
80-
Samples/Basic.swift,
81-
Samples/GlassFlower.swift,
82-
Samples/GlassFlowerRotate.swift,
83-
Samples/Input.swift,
84-
Samples/Liquefied.swift,
80+
Samples/_BlankTemplate.swift,
81+
Samples/Advanced/GlassFlower/GlassFlower.swift,
82+
Samples/Advanced/GlassFlower/GlassFlowerRotate.swift,
83+
Samples/Advanced/Liquefied.swift,
84+
Samples/Essential/Basic.swift,
85+
Samples/Essential/Buttons.swift,
86+
Samples/Essential/Input.swift,
87+
"Samples/Style Helpers/Colors.swift",
8588
);
8689
target = 3A80CECB2DB4C144006BDD0A /* Watch Watch App */;
8790
};
@@ -650,9 +653,12 @@
650653
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
651654
CODE_SIGN_ENTITLEMENTS = Demo/Demo.entitlements;
652655
CODE_SIGN_STYLE = Automatic;
653-
CURRENT_PROJECT_VERSION = 9;
656+
CURRENT_PROJECT_VERSION = 10;
657+
DEVELOPMENT_TEAM = "";
654658
ENABLE_PREVIEWS = YES;
655659
GENERATE_INFOPLIST_FILE = YES;
660+
INFOPLIST_KEY_CFBundleDisplayName = Demo;
661+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
656662
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
657663
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
658664
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
@@ -663,11 +669,11 @@
663669
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
664670
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
665671
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
666-
IPHONEOS_DEPLOYMENT_TARGET = 18.4;
672+
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
667673
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
668674
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
669-
MACOSX_DEPLOYMENT_TARGET = 15.4;
670-
MARKETING_VERSION = 1.7.0;
675+
MACOSX_DEPLOYMENT_TARGET = 14.0;
676+
MARKETING_VERSION = 1.8.0;
671677
PRODUCT_BUNDLE_IDENTIFIER = media.1998.Demo;
672678
PRODUCT_NAME = "$(TARGET_NAME)";
673679
REGISTER_APP_GROUPS = YES;
@@ -677,7 +683,8 @@
677683
SWIFT_EMIT_LOC_STRINGS = YES;
678684
SWIFT_VERSION = 5.0;
679685
TARGETED_DEVICE_FAMILY = "1,2,3,7";
680-
XROS_DEPLOYMENT_TARGET = 2.4;
686+
TVOS_DEPLOYMENT_TARGET = 15.0;
687+
XROS_DEPLOYMENT_TARGET = 1.0;
681688
};
682689
name = Debug;
683690
};
@@ -688,9 +695,12 @@
688695
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
689696
CODE_SIGN_ENTITLEMENTS = Demo/Demo.entitlements;
690697
CODE_SIGN_STYLE = Automatic;
691-
CURRENT_PROJECT_VERSION = 9;
698+
CURRENT_PROJECT_VERSION = 10;
699+
DEVELOPMENT_TEAM = "";
692700
ENABLE_PREVIEWS = YES;
693701
GENERATE_INFOPLIST_FILE = YES;
702+
INFOPLIST_KEY_CFBundleDisplayName = Demo;
703+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
694704
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
695705
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
696706
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
@@ -701,11 +711,11 @@
701711
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
702712
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
703713
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
704-
IPHONEOS_DEPLOYMENT_TARGET = 18.4;
714+
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
705715
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
706716
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
707-
MACOSX_DEPLOYMENT_TARGET = 15.4;
708-
MARKETING_VERSION = 1.7.0;
717+
MACOSX_DEPLOYMENT_TARGET = 14.0;
718+
MARKETING_VERSION = 1.8.0;
709719
PRODUCT_BUNDLE_IDENTIFIER = media.1998.Demo;
710720
PRODUCT_NAME = "$(TARGET_NAME)";
711721
REGISTER_APP_GROUPS = YES;
@@ -715,7 +725,8 @@
715725
SWIFT_EMIT_LOC_STRINGS = YES;
716726
SWIFT_VERSION = 5.0;
717727
TARGETED_DEVICE_FAMILY = "1,2,3,7";
718-
XROS_DEPLOYMENT_TARGET = 2.4;
728+
TVOS_DEPLOYMENT_TARGET = 15.0;
729+
XROS_DEPLOYMENT_TARGET = 1.0;
719730
};
720731
name = Release;
721732
};
@@ -811,7 +822,7 @@
811822
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
812823
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
813824
CODE_SIGN_STYLE = Automatic;
814-
CURRENT_PROJECT_VERSION = 9;
825+
CURRENT_PROJECT_VERSION = 10;
815826
DEVELOPMENT_TEAM = "";
816827
ENABLE_PREVIEWS = YES;
817828
GENERATE_INFOPLIST_FILE = YES;
@@ -822,15 +833,15 @@
822833
"$(inherited)",
823834
"@executable_path/Frameworks",
824835
);
825-
MARKETING_VERSION = 1.7.0;
836+
MARKETING_VERSION = 1.8.0;
826837
PRODUCT_BUNDLE_IDENTIFIER = media.1998.Demo.watchkitapp;
827838
PRODUCT_NAME = "$(TARGET_NAME)";
828839
SDKROOT = watchos;
829840
SKIP_INSTALL = YES;
830841
SWIFT_EMIT_LOC_STRINGS = YES;
831842
SWIFT_VERSION = 5.0;
832843
TARGETED_DEVICE_FAMILY = 4;
833-
WATCHOS_DEPLOYMENT_TARGET = 11.4;
844+
WATCHOS_DEPLOYMENT_TARGET = 10.0;
834845
};
835846
name = Debug;
836847
};
@@ -840,7 +851,7 @@
840851
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
841852
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
842853
CODE_SIGN_STYLE = Automatic;
843-
CURRENT_PROJECT_VERSION = 9;
854+
CURRENT_PROJECT_VERSION = 10;
844855
DEVELOPMENT_TEAM = "";
845856
ENABLE_PREVIEWS = YES;
846857
GENERATE_INFOPLIST_FILE = YES;
@@ -851,7 +862,7 @@
851862
"$(inherited)",
852863
"@executable_path/Frameworks",
853864
);
854-
MARKETING_VERSION = 1.7.0;
865+
MARKETING_VERSION = 1.8.0;
855866
PRODUCT_BUNDLE_IDENTIFIER = media.1998.Demo.watchkitapp;
856867
PRODUCT_NAME = "$(TARGET_NAME)";
857868
SDKROOT = watchos;
@@ -860,7 +871,7 @@
860871
SWIFT_VERSION = 5.0;
861872
TARGETED_DEVICE_FAMILY = 4;
862873
VALIDATE_PRODUCT = YES;
863-
WATCHOS_DEPLOYMENT_TARGET = 11.4;
874+
WATCHOS_DEPLOYMENT_TARGET = 10.0;
864875
};
865876
name = Release;
866877
};

Demo/Demo/Samples/GlassFlower.swift renamed to Demo/Demo/Samples/Advanced/GlassFlower/GlassFlower.swift

File renamed without changes.

Demo/Demo/Samples/GlassFlowerRotate.swift renamed to Demo/Demo/Samples/Advanced/GlassFlower/GlassFlowerRotate.swift

File renamed without changes.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
//
2+
// Liquefied.swift
3+
// Demo
4+
//
5+
// Created by Ming on 21/4/2025.
6+
//
7+
8+
import SwiftUI
9+
import SwiftGlass
10+
11+
struct Liquefied: View {
12+
var showBubbles: Bool = false
13+
14+
@State private var colorIndex: Int = 0
15+
@State private var timer: Timer? = nil
16+
17+
// Use computed properties to get current color and name
18+
private var color: Color {
19+
// Get the current color from colorOptions
20+
return colorOptions[colorIndex].color
21+
}
22+
23+
private var colorName: String {
24+
// Get the current color name from colorOptions
25+
return colorOptions[colorIndex].name
26+
}
27+
28+
var body: some View {
29+
ZStack {
30+
// Background color with opacity
31+
color
32+
.opacity(0.2)
33+
.ignoresSafeArea()
34+
VStack {
35+
Spacer()
36+
37+
// Animated color name text
38+
Text(colorIndex == 0 ? "" : colorName)
39+
.font(.title2)
40+
.fontWeight(.heavy)
41+
.foregroundStyle(color)
42+
.padding(colorIndex == 0 ? 0 : 100)
43+
.liquefiedGlass(color: color, blobIntensity: 0.2)
44+
.contentTransition(.numericText(countsDown: true))
45+
46+
if colorIndex == 0 {
47+
Spacer()
48+
}
49+
50+
if showBubbles {
51+
thinkingBubbles
52+
}
53+
54+
Spacer()
55+
56+
if showBubbles {
57+
footer
58+
}
59+
}
60+
.multilineTextAlignment(.center)
61+
.padding(.horizontal)
62+
}
63+
.onAppear {
64+
// Start timer to cycle colors
65+
timer = Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { _ in
66+
withAnimation(.easeInOut(duration: 1.5)) {
67+
colorIndex = (colorIndex + 1) % colorOptions.count
68+
}
69+
}
70+
}
71+
.onDisappear {
72+
// Invalidate timer when view disappears
73+
timer?.invalidate()
74+
timer = nil
75+
}
76+
}
77+
78+
var thinkingBubbles: some View {
79+
ForEach(Array(zip([100, 50, 30, 10], [
80+
CGPoint(x: 40, y: 15),
81+
CGPoint(x: 70, y: 30),
82+
CGPoint(x: 90, y: 50),
83+
CGPoint(x: 110, y: 65),
84+
])), id: \.0) { size, offset in
85+
Circle()
86+
.fill(.clear)
87+
.liquefiedGlass(color: color, blobIntensity: 0.2)
88+
.frame(width: colorIndex == 0 ? 0 : CGFloat(size), height: colorIndex == 0 ? 0 : CGFloat(size))
89+
.offset(x: offset.x, y: offset.y)
90+
}
91+
}
92+
93+
var footer: some View {
94+
HStack {
95+
Spacer()
96+
Text("SwiftGlass 1.7 - Liquefied")
97+
.bold()
98+
.font(.caption)
99+
.foregroundStyle(color)
100+
.padding(25)
101+
.glass(color: color, shadowColor: color)
102+
}
103+
}
104+
}
105+
106+
#Preview("Bubble") {
107+
Liquefied()
108+
.preferredColorScheme(.dark)
109+
}
110+
111+
#Preview("Bubbles") {
112+
Liquefied(showBubbles: true)
113+
.preferredColorScheme(.dark)
114+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct Basic: View {
102102
.scaledToFill()
103103
} placeholder: {
104104
ProgressView()
105-
}.opacity(0.6)
105+
}.opacity(0.3)
106106
.ignoresSafeArea()
107107
}
108108
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Buttons.swift
3+
// Demo
4+
//
5+
// Created by Ming on 22/4/2025.
6+
//
7+
8+
import SwiftUI
9+
import SwiftGlass
10+
11+
struct Buttons: View {
12+
var body: some View {
13+
NavigationStack {
14+
deleteButton
15+
16+
#if !os(watchOS)
17+
.toolbar {
18+
ToolbarItemGroup(placement: .navigationBarLeading) {
19+
Button(action: {}) {
20+
HStack(spacing: 3) {
21+
Image(systemName: "chevron.left")
22+
.font(.caption)
23+
.padding(.leading, 6)
24+
Text("Back")
25+
.bold()
26+
.padding(.trailing, 1.5)
27+
}
28+
.padding(.vertical, 2)
29+
.accentColor(.primary)
30+
}.background(.primary.opacity(0.1))
31+
.glass(color: .primary, shadowColor: .primary.opacity(0.75))
32+
}
33+
34+
ToolbarItemGroup(placement: .navigationBarTrailing) {
35+
EditButton()
36+
.bold()
37+
.padding(.vertical, 3)
38+
.padding(.leading, 5)
39+
.padding(.trailing, 11.5)
40+
.background(Color.accentColor.opacity(0.1))
41+
.glass(color: .accentColor, shadowColor: .accentColor)
42+
}
43+
}
44+
#endif
45+
}
46+
}
47+
48+
var deleteButton: some View {
49+
Button(action: {}) {
50+
Text("Hold to Delete!")
51+
.bold()
52+
.padding(25)
53+
.foregroundStyle(.red)
54+
}.background(.red.opacity(0.1))
55+
.glass(color: .red, shadowColor: .red)
56+
}
57+
}
58+
59+
#Preview("Dark") {
60+
Buttons()
61+
.preferredColorScheme(.dark)
62+
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ struct Input: View {
3333
}
3434
}
3535

36-
#Preview("Light") {
37-
Input()
38-
}
39-
40-
#Preview("Dark") {
36+
@available(iOS 17.0, *)
37+
#Preview("Dark", traits: .landscapeLeft) {
4138
Input()
4239
.preferredColorScheme(.dark)
40+
4341
}

0 commit comments

Comments
 (0)