Files
SodaLive
Preview Content
Resources
Sources
Agora
App
Common
Content
CustomView
Debug
Dialog
CommunityPostPurchaseDialog.swift
LivePaymentDialog.swift
LiveRoomPasswordDialog.swift
SodaDialog.swift
Explorer
Extensions
Follow
Font
FortuneWheel
IAP
ImagePicker
Keyboard
Live
Main
Message
MyPage
NavigationBar
Onboarding
Report
Settings
Shape
Splash
UI
User
Utils
ContentView.swift
SodaLive.entitlements
SodaLive.xcworkspace
generated
.gitignore
Podfile
Podfile.lock
SodaLive-dev.entitlements
model-SodaLive-dev.json
model-SodaLive.json
sodalive-ios/SodaLive/Sources/Dialog/SodaDialog.swift

108 lines
3.9 KiB
Swift

//
// SodaDialog.swift
// SodaLive
//
// Created by klaus on 2023/08/10.
//
import SwiftUI
struct SodaDialog: View {
let title: String
let desc: String
let confirmButtonTitle: String
let confirmButtonAction: () -> Void
let cancelButtonTitle: String
let cancelButtonAction: () -> Void
init(
title: String,
desc: String,
confirmButtonTitle: String,
confirmButtonAction: @escaping () -> Void,
cancelButtonTitle: String = "",
cancelButtonAction: @escaping () -> Void = {}
) {
self.title = title
self.desc = desc
self.confirmButtonTitle = confirmButtonTitle
self.confirmButtonAction = confirmButtonAction
self.cancelButtonTitle = cancelButtonTitle
self.cancelButtonAction = cancelButtonAction
}
var body: some View {
GeometryReader { geo in
ZStack {
Color.black
.opacity(0.5)
.frame(width: geo.size.width, height: geo.size.height)
VStack(spacing: 0) {
Text(title)
.font(.custom(Font.bold.rawValue, size: 18.3))
.foregroundColor(Color(hex: "bbbbbb"))
.padding(.top, 40)
Text(desc)
.font(.custom(Font.medium.rawValue, size: 15))
.foregroundColor(Color(hex: "bbbbbb"))
.multilineTextAlignment(.center)
.padding(.top, 12)
.padding(.horizontal, 13.3)
.fixedSize(horizontal: false, vertical: true)
HStack(spacing: 13.3) {
if cancelButtonTitle.count > 0 {
Text(cancelButtonTitle)
.font(.custom(Font.bold.rawValue, size: 15.3))
.foregroundColor(Color(hex: "3bb9f1"))
.padding(.vertical, 16)
.frame(width: (geo.size.width - 66.7) / 3)
.background(Color(hex: "13181b"))
.cornerRadius(8)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(Color(hex: "3bb9f1"), lineWidth: 1)
)
.onTapGesture {
cancelButtonAction()
}
}
Text(confirmButtonTitle)
.font(.custom(Font.bold.rawValue, size: 15.3))
.foregroundColor(Color(hex: "ffffff"))
.padding(.vertical, 16)
.frame(width: (geo.size.width - 66.7) * 2 / 3)
.background(Color(hex: "3bb9f1"))
.cornerRadius(8)
.onTapGesture {
confirmButtonAction()
}
}
.padding(.top, 45)
.padding(.bottom, 16.7)
}
.frame(width: geo.size.width - 26.7, alignment: .center)
.background(Color(hex: "222222"))
.cornerRadius(10)
}
}
}
}
struct SodaDialog_Previews: PreviewProvider {
static var previews: some View {
SodaDialog(
title: "작성글 등록",
desc: "작성한 글을 등록하시겠습니까?",
confirmButtonTitle: "결제 후 입장",
confirmButtonAction: {},
cancelButtonTitle: "취소",
cancelButtonAction: {}
)
}
}