Files
sodalive-ios/SodaLive/Sources/Settings/SignOut/SignOutView.swift

127 lines
6.2 KiB
Swift

//
// SignOutView.swift
// SodaLive
//
// Created by klaus on 2023/08/10.
//
import SwiftUI
struct SignOutView: View {
@StateObject var viewModel = SignOutViewModel()
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
VStack(spacing: 0) {
DetailNavigationBar(title: I18n.Settings.SignOut.title)
ScrollView(.vertical, showsIndicators: false) {
VStack(spacing: 0) {
VStack(spacing: 13.3) {
Text(I18n.Settings.SignOut.headline)
.appFont(size: 20, weight: .bold)
.foregroundColor(Color(hex: "3bb9f1"))
.frame(width: screenSize().width - 26.7, alignment: .leading)
Text(I18n.Settings.SignOut.reasonGuide)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(Color(hex: "eeeeee"))
.frame(width: screenSize().width - 26.7, alignment: .leading)
VStack(alignment: .leading, spacing: 16.7) {
ForEach(0..<viewModel.reasons.count, id: \.self) { index in
let reason = viewModel.reasons[index]
HStack(spacing: 13.3) {
Image(
viewModel.reasonSelectedIndex == index ?
"btn_radio_select_selected" :
"btn_radio_select_normal"
)
.resizable()
.frame(width: 20, height: 20)
Text(reason)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(Color(hex: "eeeeee"))
if index == viewModel.reasons.count - 1 {
VStack(spacing: 6.7) {
TextField(I18n.Settings.SignOut.reasonInputPlaceholder, text: $viewModel.reason)
.autocapitalization(.none)
.disableAutocorrection(true)
.appFont(size: 13.3, weight: .medium)
.foregroundColor(Color(hex: "eeeeee"))
.keyboardType(.webSearch)
Rectangle()
.frame(height: 1)
.foregroundColor(Color(hex: "909090").opacity(0.5))
}
}
}
.onTapGesture {
viewModel.reasonSelectedIndex = index
}
}
}
.padding(.top, 13.3)
.padding(.horizontal, 16.7)
Rectangle()
.frame(width: screenSize().width, height: 6.7)
.foregroundColor(Color(hex: "232323"))
.padding(.top, 20)
Text(I18n.Settings.SignOut.accountDeletionNotice)
.appFont(size: 12, weight: .medium)
.foregroundColor(Color(hex: "ff5c49"))
.fixedSize(horizontal: false, vertical: true)
.padding(.horizontal, 26.7)
.padding(.top, 16.7)
UserTextField(
title: I18n.Settings.SignOut.passwordTitle,
hint: I18n.Settings.SignOut.passwordPlaceholder,
isSecure: true,
variable: $viewModel.password,
keyboardType: .emailAddress
)
.padding(.top, 20)
.padding(.horizontal, 26.7)
Text(I18n.Settings.SignOut.socialLoginGuide)
.appFont(size: 12, weight: .medium)
.foregroundColor(.grayee)
.fixedSize(horizontal: false, vertical: true)
.padding(.horizontal, 26.7)
.padding(.top, 8)
Text(I18n.Settings.SignOut.submit)
.appFont(size: 15, weight: .bold)
.foregroundColor(.white)
.padding(.vertical, 16)
.frame(width: screenSize().width - 26.7)
.background(Color(hex: "3bb9f1"))
.cornerRadius(6.7)
.padding(.top, 26.7)
.onTapGesture {
viewModel.signOut()
}
}
.padding(.top, 26.7)
}
}
}
}
.sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2)
}
}
struct SignOutView_Previews: PreviewProvider {
static var previews: some View {
SignOutView()
}
}