//
|
// Untitled.swift
|
// LiveProject
|
//
|
// Created by 倪路朋 on 6/25/25.
|
//
|
|
|
import SwiftUI
|
|
struct LButton: View {
|
|
var valid :ValidState = .VALID;
|
|
var icon : (any View)? = nil;
|
|
var text = "";
|
|
var onClick : () -> Void = {
|
|
}
|
|
var body: some View {
|
Button(action: {
|
if(valid == .INVALID){
|
return
|
}
|
onClick();
|
}) {
|
|
ZStack() {// iOS
|
HStack() {// iOS
|
if let shape = icon {
|
AnyView(shape)
|
}
|
Text(text)
|
.font(Font.system(size: 16))
|
.foregroundColor(Color.init("ColorWhite"))
|
.frame(width: .infinity, height: 40)
|
}.frame(minWidth: 40, maxHeight: 40).padding(EdgeInsets(top: 0, leading: 15, bottom: 0, trailing: 15))
|
}.frame(maxHeight: 40).background(
|
RoundedRectangle(cornerRadius: 20, style: .continuous)
|
.fill(valid == .VALID ? Color.colorPrimary:Color.colorGray)
|
)
|
|
}.buttonStyle( TextBtnStyle())
|
}
|
}
|
|
struct AButton_Previews: PreviewProvider {
|
static var previews: some View {
|
LButton()
|
}
|
}
|