1๏ธโฃ CustomButton
- type: ButtonType ์ฌ์ฉํด์ ์ง์ (default: large, square)
@State var buttonState: ButtonState = .disable
CustomButton(action: {
// ์ํํ ์ก์
}, label: {
Text("CustomButton (default)")
}, state: $buttonState)
CustomButton(action: {
// ์ํํ ์ก์
}, label: {
Text("CustomButton (small, round)")
}, state: $buttonState,
type: ButtonType(size: .small, shape: .round)) // ์ํ๋ ํ์
์ง์
2๏ธโฃ CustomButtonStyle
- NavigationLink์ ๊ฐ์ด ๊ฐ์ ์ ์ผ๋ก ์์ฑ๋๋ ๋ฒํผ์ ์ฌ์ฉ
- CustButtonStyle ์ฌ์ฉํ์ฌ type๊ณผ state ์ถ๊ฐ ํ buttonStyle ์ง์
NavigationLink(destination: TempView()) {
Text("CusomButtonStyle (medium, round)")
}
.buttonStyle(
CustomButtonStyle(
type: ButtonType(size: .medium, shape: .square),
state: $statethree)
)
@State var nameTextField: String = ""
@State var hobbyTextField: String = ""
CustomTextField(
textfield: $nameTextField,
placeholder: "์ด๋ฆ์ ์
๋ ฅํด์ฃผ์ธ์",
type: .basic,
maxCount: 20 // ์ ํ
)
.padding()
CustomTextField(
textfield: $hobbyTextField,
placeholder: "์ทจ๋ฏธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์",
type: .title("์ทจ๋ฏธ ์ ๋ณด"),
buttonType: .other("checkmark") // ์ ํ (default: .delete)
)
.padding()
1๏ธโฃ Custom BottomSheet
BottomSheet(isShowing: $isShowing, type: .medium, content: {
// BottomSheet์ ๋ค์ด๊ฐ ์ปจํ
์ธ ์์ฑ
})
.edgesIgnoringSafeArea(.all)
2๏ธโฃ presentationDetents ์ฌ์ฉํ BottomSheet ์์
@State var isPresented: Bool = false
Button {
// ๋ฒํผ ์ก์
isPresented.toggle()
} label: {
// ๋ฒํผ ํ์ดํ
}
.sheet(isPresented: $isPresented) {
VStack(spacing: 20) {
// BottomSheet ์ปจํ
์ธ
}
.padding(EdgeInsets(top: 20, leading: 0, bottom: 20, trailing: 0))
.presentationDetents([.fraction(0.5), .fraction(0.2)]) // fraction, ๊ธฐ๋ณธ detent(.large, .medium), height ๋ฑ ์ฌ์ฉํ์ฌ ๋๋๊ทธ ๊ฐ๋ฅํ ๋์ด ์ค์ ๊ฐ๋ฅ
.presentationDragIndicator(.visible)
}
@State private var isPresented: Bool = false
@State private var alertButtonTapped: Bool = false
CustomAlert(isPresented: $isPresented,
title: "ํ์ดํ๋ง ์๋ alert",
rightButtonAction: $alertButtonTapped)
CustomAlert(isPresented: $isPresented,
title: "๋๋ค ์๋ alert",
description: "ํ์ดํ๋ ์๊ณ ์ค๋ช
๋ ์๋ alert์
๋๋ค.\n ์๋
ํ์ธ์ฉ ๋ฐ๊ฐ์ต๋๋น",
rightButtonAction: $alertButtonTapped)