yangsubinn / SwiftUIKit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwiftUIKit

ButtonStyle

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)
)

TextField

ezgif com-resize (5)

@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()

BottomSheet

ezgif com-resize (7)

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)
}

Alert

ezgif com-resize (8)

@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)

About


Languages

Language:Swift 100.0%