Taehyeon-Kim / Taehyeon-Kim.github.io

The life of recording is unbreakable
https://taehyeon-kim.github.io
MIT License
1 stars 0 forks source link

SwiftUI101: KeyboardTypeModifier #32

Open Taehyeon-Kim opened 9 months ago

Taehyeon-Kim commented 9 months ago
import SwiftUI

struct KeyboardTypeModifier: ViewModifier {
  let type: UserInformationType

  func body(content: Content) -> some View {
    Group {
      switch type {
      case .nickname:
        content.keyboardType(.default)
      case .email:
        content.keyboardType(.emailAddress)
      case .phoneNumber:
        content.keyboardType(.numberPad)
      case .mbti:
        content.keyboardType(.alphabet)
      case .diaryFrequency:
        content.keyboardType(.numberPad)
      }
    }
  }
}