[ad_1]
I have to display like the following , used three VStacks to display it. However the login VStack is to the bottom of the screen. How to place it to the center of the screen and Google image to the top most of the screen
struct Login: View {
var body: some View {
ZStack{
CustomNavigationBar() // To diplay image
VStack{
LoginView(lgnvwmmodel: lgnvwmmodel) //To display Login View
HelpView()
}
}
}
}
struct CustomNavigationBar: View{
var body: some View{
NavigationView{
Image(uiImage: UIImage(named: "google.png")!)
} .navigationViewStyle(StackNavigationViewStyle())
.navigationBarTitleDisplayMode(.inline)
.padding(0)
}
}
struct LoginView: View {
@State private var emailId: String = ""
@State private var password: String = ""
@State var ntwrkShowAlert = false
@State private var success = false
@State var isModal:Bool = false
@EnvironmentObject var DataGetting : DataStorage
@ObservedObject var monitor = NetworkMonitor()
@State private var isEmailValid : Bool = true
@State private var showingAlert = false
@State var chngpasscode = false
@State var btnClicked:CancelClicked = .none
@State var showPopup = false
@ObservedObject var lgnvwmmodel : LoginViewModel
var body: some View {
Text("Login")
.font(.custom("OpenSans-Bold", size: 24))
.padding(.top, 100)
TextField("Email ID", text: $emailId)
.onReceive(Just(emailId), perform: { _ in
if emailId.count >= 50{
emailId = String(emailId.prefix(50))
}
})
.modifier(customViewModifier(roundedCornes: 6, textColor: .black))
.frame(height: 100)
.padding([.leading, .trailing], 100)
SecureField("Password", text: $password)
.onReceive(Just(password), perform: { _ in
if password.count >= 50{
password = String(password.prefix(50))
}
})
.modifier(customViewModifier(roundedCornes: 6, textColor: .black))
.frame(height: 100)
.padding([.leading, .trailing], 100)
Button(action: {
}, label: {
Text("Forgot Password ?")
.underline()
.frame( height: 40, alignment: .trailing)
.padding(.leading, 320)
})
Button(action: {
if(DataGetting.strEmail == ""){
UserDefaults.standard.setValue(self.emailId, forKey:"Email")
}
if((DataGetting.strPassword) == 0){
UserDefaults.standard.setValue(self.password, forKey: "Password")
}
self.isModal = true
if(monitor.status == .connected){
self.ntwrkShowAlert = false
lgnvwmmodel.dataStorage = DataGetting
lgnvwmmodel.getUserIdDetails(emailId: emailId, password: password){ status in
do {
if(status){
success = true
}
}
}
}
else{
self.ntwrkShowAlert = true
}
}, label: {
Text("Sign In")
.frame(width: 200, height: 30)
.padding()
.background(Color.red)
.foregroundColor(Color.white)
.font(.custom("OpenSans-Bold", size: 28))
}).alert(isPresented: $ntwrkShowAlert){
return Alert(title: Text("Please check your internet connection"), message: Text(""), dismissButton: .default(Text("OK")))
}
}
}
struct HelpView: View{
@State private var isAlert = false
@State private var errorMessage: String = ""
var body: some View{
Button(action: {
}, label: {
Text("Help")
.frame(minWidth: 0, maxWidth: .infinity, maxHeight: 80)
.background(Color.red)
.foregroundColor(Color.white)
.font(.custom("OpenSans-Bold", size: 28))
}).alert(isPresented: $isAlert){
Alert(title: Text(self.errorMessage), message: Text(""), dismissButton: .default(Text("OK")))
}
}
}
[ad_2]