Skip to content

Commit 2027ce7

Browse files
committed
Add Input Field
1 parent 5c0d0d5 commit 2027ce7

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
Samples/Basic.swift,
8181
Samples/GlassFlower.swift,
8282
Samples/GlassFlowerRotate.swift,
83+
Samples/Input.swift,
8384
);
8485
target = 3A80CECB2DB4C144006BDD0A /* Watch Watch App */;
8586
};

Demo/Demo/Samples/Input.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Input.swift
3+
// Demo
4+
//
5+
// Created by Ming on 21/4/2025.
6+
//
7+
8+
import SwiftUI
9+
import SwiftGlass
10+
11+
struct Input: View {
12+
@State var content: String = ""
13+
@FocusState var focus: Bool
14+
15+
var body: some View {
16+
17+
TextField("Placeholder...", text: $content)
18+
.focused($focus)
19+
.font(.largeTitle)
20+
.textFieldStyle(.plain)
21+
.padding(25)
22+
.background(
23+
Color.accentColor
24+
.opacity(focus ? 0.3 : 0.05)
25+
)
26+
.glass(
27+
color: focus ? .accentColor : .white,
28+
shadowColor: focus ? .accentColor : .white
29+
)
30+
.padding(50)
31+
32+
.animation(.default)
33+
}
34+
}
35+
36+
#Preview("Light") {
37+
Input()
38+
}
39+
40+
#Preview("Dark") {
41+
Input()
42+
.preferredColorScheme(.dark)
43+
}

0 commit comments

Comments
 (0)