-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAddNicknameView.swift
More file actions
89 lines (83 loc) · 2.57 KB
/
AddNicknameView.swift
File metadata and controls
89 lines (83 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// AddNicknameView.swift
// XcodeTips
//
// Created by Moon Jongseek on 8/10/24.
//
import SwiftUI
struct AddNicknameView: View {
var model: CardModel
@State var isShowAlert: Bool = false
@State var isPresented: Bool = false
@State var nickname: String = ""
var body: some View {
VStack(spacing: 20) {
Text(Title.addNickname.value)
.font(.title)
.padding(.top)
// 카드
CardView(model: model) {
Group {
TextField(
"닉네임",
text: $nickname,
prompt: Text("닉네임").foregroundColor(.gray),
axis: .horizontal
)
.font(.title)
.foregroundColor(model.mode == .light ? .black : .white)
.multilineTextAlignment(.center)
.padding(5)
.frame(height: 40)
.clipped()
.overlay {
RoundedRectangle(cornerRadius: 5)
.stroke(lineWidth: 1)
.foregroundColor(Color(red: 200/255, green: 200/255, blue: 200/255))
}
Spacer()
}
}
Spacer()
// Next Button
Button {
if nickname.isEmpty {
isShowAlert.toggle()
} else {
isPresented.toggle()
}
} label: {
ZStack {
RoundedRectangle(cornerRadius: 5, style: .circular)
.fill(Color.blue)
Text("Next")
.foregroundStyle(Color.white)
}
}
.navigationDestination(isPresented: $isPresented) {
AddMemojiView(
model: CardModel(
mode: model.mode,
name: nickname
)
)
}
.frame(height: 44)
.padding(.bottom, 40)
}
.padding([.horizontal], 50)
.ignoresSafeArea(.keyboard)
// 주석 단축키 ⌘(command) + /
.alert(
"닉네임을 입력해주세요.",
isPresented: $isShowAlert
) {
Button("확인") {
isShowAlert.toggle()
}
}
}
}
#Preview {
AddNicknameView(model: .init(mode: .dark))
}