Files
sodalive-ios/SodaLive/Sources/MyPage/Profile/Nickname/NicknameUpdateView.swift

93 lines
3.9 KiB
Swift

//
// NicknameUpdateView.swift
// SodaLive
//
// Created by klaus on 2023/08/19.
//
import SwiftUI
struct NicknameUpdateView: View {
@StateObject var viewModel = NicknameUpdateViewModel()
@StateObject var keyboardHandler = KeyboardHandler()
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
GeometryReader { proxy in
VStack(spacing: 0) {
DetailNavigationBar(title: I18n.MyPage.Main.editProfile)
Text(I18n.MyPage.Nickname.paidChangeNotice)
.fixedSize(horizontal: false, vertical: true)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(Color(hex: "eeeeee"))
.frame(width: screenSize().width - 40, alignment: .leading)
.padding(.top, 40)
Text(I18n.MyPage.Nickname.firstFreeNotice)
.fixedSize(horizontal: false, vertical: true)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(Color(hex: "dd4500"))
.frame(width: screenSize().width - 40, alignment: .leading)
UserTextField(
title: I18n.ProfileUpdate.nicknameTitle,
hint: I18n.ProfileUpdate.nicknameHint,
isSecure: false,
variable: $viewModel.nickname
)
.frame(width: screenSize().width - 40)
.padding(.top, 40)
Text(I18n.MyPage.Nickname.duplicateCheckAction)
.appFont(size: 13.3, weight: .bold)
.foregroundColor(Color(hex: "eeeeee"))
.frame(width: screenSize().width - 40)
.padding(.vertical, 13.3)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(Color(hex: "3bb9f1"), lineWidth: 1)
)
.padding(.top, 21.3)
.onTapGesture {
hideKeyboard()
viewModel.checkNickname()
}
Spacer()
Text(viewModel.price > 0 ? I18n.MyPage.Nickname.changeActionWithCans(viewModel.price) : I18n.MyPage.Nickname.changeAction)
.appFont(size: 18.3, weight: .bold)
.foregroundColor(Color.white)
.padding(.vertical, 16)
.frame(width: screenSize().width - 26.7)
.background(Color(hex: "3bb9f1"))
.cornerRadius(10)
.padding(.vertical, 13.7)
.frame(width: screenSize().width)
.background(Color(hex: "222222"))
.cornerRadius(16.7)
.padding(.top, 13.3)
.onTapGesture { viewModel.changeNickname() }
if proxy.safeAreaInsets.bottom > 0 {
Rectangle()
.foregroundColor(Color.black)
.frame(width: proxy.size.width, height: 15.3)
}
}
.edgesIgnoringSafeArea(.bottom)
.onTapGesture {
hideKeyboard()
}
}
.onAppear {
viewModel.nickname = UserDefaults.string(forKey: .nickname)
viewModel.getChangeNicknamePrice()
}
.sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2)
}
}
}