[♻️] 문제 되는 버튼 뷰 해결 및 버튼 뷰 구성 수정
This commit is contained in:
parent
3beafd636b
commit
48f564d051
Binary file not shown.
|
@ -15,10 +15,18 @@ struct CircleBtnView: View {
|
|||
|
||||
var body: some View {
|
||||
if let state = vm.btnStates[id] {
|
||||
Button{
|
||||
guard let action = state.action else {return}
|
||||
action()
|
||||
} label: {
|
||||
ZStack {
|
||||
if state.isReverse {
|
||||
Circle()
|
||||
.foregroundStyle(state.backColor)
|
||||
.frame(width: state.width, height: state.height)
|
||||
.innerShadow(shape: Circle(), color: Color(.Text.black).opacity(0.75), blur: 8, x: 0, y: 4)
|
||||
} else {
|
||||
Circle()
|
||||
.foregroundStyle(state.backColor)
|
||||
.frame(width: state.width, height: state.height)
|
||||
.shadow(color: Color(.Text.black).opacity(0.75), radius: 8, x: 4, y: 8)
|
||||
}
|
||||
VStack(alignment: .center, spacing: 0) {
|
||||
if let image = state.image {
|
||||
image
|
||||
|
@ -27,30 +35,20 @@ struct CircleBtnView: View {
|
|||
.foregroundStyle(state.foreColor)
|
||||
.frame(width: state.width/2, height: state.height/2)
|
||||
}
|
||||
//
|
||||
if let title = state.title, let font = state.font {
|
||||
Text("\(title)")
|
||||
.font(font)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.5)
|
||||
.truncationMode(.tail)
|
||||
.foregroundStyle(state.textColor)
|
||||
// .padding()
|
||||
.foregroundStyle(state.foreColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
.background {
|
||||
if state.isReverse {
|
||||
Circle()
|
||||
.accentColor(state.backColor)
|
||||
.frame(width: state.width, height: state.height)
|
||||
.innerShadow(shape: Circle(), color: Color(.Text.black).opacity(0.75), blur: 8, x: 0, y: 4)
|
||||
} else {
|
||||
Circle()
|
||||
.accentColor(state.backColor)
|
||||
.frame(width: state.width, height: state.height)
|
||||
.shadow(color: Color(.Text.black).opacity(0.75), radius: 8, x: 4, y: 8)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
guard let action = state.action else {return}
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,7 @@ struct BottomView: View {
|
|||
|
||||
}
|
||||
}
|
||||
// MARK: TO-DO
|
||||
// 이거 패딩 제대로 안먹는거 이유 찾기
|
||||
.padding([.top],12)
|
||||
.padding([.horizontal],24)
|
||||
// .padding(EdgeInsets(top: 12, leading: 24, bottom: 0, trailing: 24))
|
||||
.padding(EdgeInsets(top: 12, leading: 24, bottom: 0, trailing: 24))
|
||||
|
||||
.background {
|
||||
Rectangle()
|
||||
|
@ -48,7 +44,7 @@ struct BottomView: View {
|
|||
|
||||
idList.enumerated().forEach { (index, id) in
|
||||
btnVM.btnStates[id] = ButtonState()
|
||||
btnVM.setSize(for: id, newWidth: 48, newHeight: 48)
|
||||
btnVM.setSize(for: id, newWidth: 52, newHeight: 52)
|
||||
btnVM.setText(for: id, newText: btnText[index],
|
||||
newFont: .nps(font: .bold, size: 6))
|
||||
btnVM.setImage(for: id, newImage: btnImage[index])
|
||||
|
|
|
@ -11,13 +11,12 @@ struct TopView: View {
|
|||
@StateObject var btnVM = ButtonViewModel()
|
||||
|
||||
@State var titleName: String = ""
|
||||
@State var changeLogo: Bool = false
|
||||
@State var tailLogo: Bool = false
|
||||
|
||||
@State private var leftBtnID = UUID()
|
||||
@State private var rightBtnID = UUID()
|
||||
|
||||
var myType: UserType = .Teacher
|
||||
//MARK: - 변경 값
|
||||
var myType: UserType = .Student
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 0) {
|
||||
|
@ -36,6 +35,7 @@ struct TopView: View {
|
|||
.foregroundStyle(Color(.Text.detail))
|
||||
.font(.nps(font: .bold, size: 20))
|
||||
Spacer()
|
||||
|
||||
SimpleBtnView(vm: btnVM, id: rightBtnID)
|
||||
.padding(EdgeInsets(top: 12, leading: 12, bottom: 12, trailing: 24))
|
||||
|
||||
|
|
|
@ -74,7 +74,11 @@ class ButtonViewModel: ObservableObject {
|
|||
func setIsReverse(for id: UUID, newValue: Bool){
|
||||
var state = btnStates[id] ?? ButtonState()
|
||||
state.isReverse = newValue
|
||||
state.backColor = newValue ? Color(.Second.light) : Color(.Normal.normal)
|
||||
if state.isReverse {
|
||||
state.backColor = Color(.Second.light)
|
||||
} else {
|
||||
state.backColor = Color(.Normal.normal)
|
||||
}
|
||||
btnStates[id] = state
|
||||
objectWillChange.send()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user