How to remove space occupied by text's if the isEditMode bool false? Could u help me how to do this?
struct HomeView : View {
@Binding var isDarkMode: Bool
@State var isEditMode = false
var body: some View {
GeometryReader { proxy in
//ZStack() {
VStack(/*spacing: 15*/) {
TopBarView(isDarkMode: self.$isDarkMode, isEditMode: self.$isEditMode)//.opacity(self.viewAppared ? 1 : 0)
ScrollView(.vertical, showsIndicators: true)
{
VStack {
ClockView(isEditMode: self.$isEditMode)
Text("apple").opacity(self.isEditMode ? 0 : 1)
Text("apple").opacity(self.isEditMode ? 0 : 1)
Text("apple").opacity(self.isEditMode ? 0 : 1)
}
}
}
//}
//Spacer()
}
}
}
The texts are looks like this, in the bottom of the ClockView:
Text("The alarm will ring at").opacity(isEditMode ? 1 : 0).padding(.bottom, 10)
Text(TimeMH().ToString(minuteAngle, hourAngle))
.opacity(isEditMode ? 1 : 0)
.font(.system(size: 25))
.background(Rectangle()
.fill(Color(UIColor.lightGray))
.frame(width: 90, height: 40)
.cornerRadius(10)
.shadow(radius: 5))
.opacity(isEditMode ? 1 : 0)
isEditMode: True
isEditMode: False
Is there a better solution? This is how I managed to solve the problem:
Group {
if isEditMode {
Text("The alarm will ring at")
.padding(.bottom, 10)
Text(TimeMH().ToString(minuteAngle, hourAngle))
.font(.system(size: 25))
.background(Rectangle()
.fill(Color(UIColor.lightGray))
.frame(width: 90, height: 40)
.cornerRadius(10)
.shadow(radius: 5))
} else {
EmptyView()
}
}