110 lines
4.7 KiB
Swift
110 lines
4.7 KiB
Swift
//
|
|
// ModifyPasswordView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2023/08/19.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ModifyPasswordView: View {
|
|
|
|
@StateObject var viewModel = ProfileUpdateViewModel()
|
|
@StateObject var keyboardHandler = KeyboardHandler()
|
|
|
|
var body: some View {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
GeometryReader { proxy in
|
|
VStack(spacing: 0) {
|
|
DetailNavigationBar(title: I18n.ProfileUpdate.modifyPasswordTitle)
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
Text(I18n.ProfileUpdate.modifyPasswordGuide)
|
|
.appFont(size: 13.3, weight: .medium)
|
|
.foregroundColor(Color.grayee)
|
|
.padding(.top, 40)
|
|
|
|
VStack(spacing: 26.7) {
|
|
UserTextField(
|
|
title: I18n.ProfileUpdate.currentPasswordTitle,
|
|
hint: I18n.ProfileUpdate.currentPasswordHint,
|
|
isSecure: true,
|
|
variable: $viewModel.currentPassword
|
|
)
|
|
|
|
UserTextField(
|
|
title: I18n.ProfileUpdate.newPasswordTitle,
|
|
hint: I18n.ProfileUpdate.newPasswordHint,
|
|
isSecure: true,
|
|
variable: $viewModel.newPassword
|
|
)
|
|
|
|
UserTextField(
|
|
title: I18n.ProfileUpdate.confirmPasswordTitle,
|
|
hint: I18n.ProfileUpdate.confirmPasswordHint,
|
|
isSecure: true,
|
|
variable: $viewModel.newPasswordConfirm
|
|
)
|
|
}
|
|
.padding(.top, 40)
|
|
.frame(width: screenSize().width - 53.4)
|
|
|
|
Text(I18n.ProfileUpdate.passwordRuleFootnote)
|
|
.appFont(size: 12, weight: .medium)
|
|
.foregroundColor(Color.mainRed3)
|
|
.frame(width: screenSize().width - 53.4, alignment: .leading)
|
|
.padding(.top, 13.7)
|
|
}
|
|
|
|
if !viewModel.isLoading {
|
|
Text(I18n.ProfileUpdate.changePasswordAction)
|
|
.appFont(size: 18.3, weight: .bold)
|
|
.foregroundColor(.white)
|
|
.padding(.vertical, 16)
|
|
.frame(width: screenSize().width - 26.7)
|
|
.background(Color.button)
|
|
.cornerRadius(10)
|
|
.padding(.vertical, 13.7)
|
|
.frame(width: screenSize().width)
|
|
.background(Color.gray22)
|
|
.cornerRadius(16.7, corners: [.topLeft, .topRight])
|
|
.onTapGesture {
|
|
hideKeyboard()
|
|
viewModel.updatePassword()
|
|
}
|
|
|
|
if proxy.safeAreaInsets.bottom > 0 {
|
|
Rectangle()
|
|
.foregroundColor(Color.gray22)
|
|
.frame(width: proxy.size.width, height: 15.3)
|
|
}
|
|
}
|
|
}
|
|
.edgesIgnoringSafeArea(.bottom)
|
|
.onTapGesture {
|
|
hideKeyboard()
|
|
}
|
|
}
|
|
}
|
|
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
|
|
GeometryReader { geo in
|
|
HStack {
|
|
Spacer()
|
|
Text(viewModel.errorMessage)
|
|
.padding(.vertical, 13.3)
|
|
.padding(.horizontal, 6.7)
|
|
.frame(width: geo.size.width - 66.7, alignment: .center)
|
|
.appFont(size: 12, weight: .medium)
|
|
.background(Color.button)
|
|
.foregroundColor(Color.white)
|
|
.multilineTextAlignment(.leading)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.cornerRadius(20)
|
|
.padding(.top, 66.7)
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|