I have a problem with the navigation link and SwiftUI. The navigation bar desapear and my scroll view go up. I have upload a video of the issue on Facebook here the link : the link of the video
This is the code of my main view :
struct MainView: View {
let date = Date()
let calendar = Calendar.current
static let formatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .short
return formatter
}()
//MARK: Properties
#ObservedObject var session = FirebaseSession()
let user = Auth.auth().currentUser
#State private var showModal = false
var body: some View {
NavigationView{
// Group {
ZStack {
if session.session != nil {
ScrollView {
VStack{
ScrollView(.horizontal, showsIndicators: false){
HStack{
NavigationLink(destination: RedactorView()) {
RedactorListItem()
}.buttonStyle(PlainButtonStyle())
RedactorListItem()
RedactorListItem()
RedactorListItem()
RedactorListItem()
RedactorListItem()
}//.padding()
}
VStack(alignment: .leading, spacing: 5) {
HStack {
Text("Les derniers médias")
.font(.largeTitle)
.bold()
Spacer()
Text("Voir plus >")
.padding(8)
.background(Color(UIColor.secondarySystemBackground))
.clipShape(Capsule())
}.padding(.horizontal)
ScrollView(.horizontal, showsIndicators: false){
HStack{
NavigationLink(destination: MotherView(viewRouter: ViewRouter())){
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
}.buttonStyle(PlainButtonStyle())
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
}
}
HStack {
Text("Les derniers articles :")
.font(.largeTitle)
.bold()
Spacer()
Text("Voir plus >")
.padding(8)
.background(Color(UIColor.secondarySystemBackground))
.clipShape(Capsule())
}.padding(.horizontal)
ArticleListRow()
ArticleListRow()
ArticleListRow()
}
}
.navigationBarTitle("WYN")
.navigationBarHidden(true)
}.navigationViewStyle(StackNavigationViewStyle()).padding(.top, 90)
ZStack{
VStack{
HStack{
VStack(alignment: .leading) {
VStack {
VStack(alignment: .leading){
HStack{
Text("What You Need")
.font(.system(.largeTitle, design: .serif))
.bold()
Spacer()
Button(action: {
self.showModal.toggle()
}) {
Image(systemName: "person.crop.circle.fill")
.font(.largeTitle)
.foregroundColor(.primary)
}
.sheet(isPresented: $showModal){
SettingView(showModal: self.$showModal)
}
}
Text("\(date, formatter : MainView.self.formatter)")
.font(.callout)
.bold()
.foregroundColor(Color(UIColor.systemGray4))
}
/*
Rectangle()
.frame(height: 2)
.cornerRadius(1)
.foregroundColor(Color(UIColor.systemGray5))
*/
}
.padding(.horizontal)
.padding(.top, 20)
}.background(Color(UIColor.systemBackground)).frame(minWidth: 0, maxWidth: .infinity).frame(height: 75)
}
Spacer()
}
}
} else {
Authentification()
}
}
.onAppear(perform: getUser)
//}
.navigationBarTitle("Menu Principal")
.navigationBarHidden(true)
}.navigationViewStyle(StackNavigationViewStyle())
}
//MARK: Functions
func getUser() {
session.listen()
}
}
and this the code of my detail view :
import SwiftUI
struct RedactorView: View {
var body: some View {
// NavigationView {
ScrollView {
VStack(alignment: .leading) {
HStack{
Image("P1")
.resizable()
.scaledToFill()
.frame(width: 115, height: 115)
.clipShape(Circle())
.padding(.trailing)
VStack(alignment: .leading){
Text("Prénom")
.font(.largeTitle)
.bold()
Text("Nom")
.font(.largeTitle)
.bold()
HStack {
VStack(alignment: .center){
Text("10")
.bold()
Text("Articles")
.foregroundColor(Color(UIColor.secondaryLabel))
}
VStack(alignment: .center){
Text("5")
.bold()
Text("Medias")
.foregroundColor(Color(UIColor.secondaryLabel))
}
}.padding(.top)
}
Spacer()
}.padding(.horizontal)
ScrollView(.horizontal, showsIndicators: false) {
HStack {
HStack{
Text("Email")
.bold()
Image(systemName: "envelope.fill")
// .foregroundColor(Color(UIColor.systemBlue))
}.foregroundColor(Color(UIColor.systemBlue))
.padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
HStack{
Text("Instagram")
.bold()
Image(systemName: "heart.fill")
}.foregroundColor(Color(hue: 0.93, saturation: 0.81, brightness: 0.84)).padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
HStack{
Text("Message")
.bold()
Image(systemName: "message.fill")
}.foregroundColor(Color(UIColor.systemGreen))
.padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
HStack{
Text("Téléphone")
.bold()
Image(systemName: "phone.fill")
}.foregroundColor(Color(UIColor.systemGreen)).padding(8)
.background(Color(UIColor.systemBackground))
.clipShape(Capsule())
.shadow(color: Color(UIColor.systemGray6), radius: 10)
}.padding()
}
VStack(alignment: .leading, spacing: 5) {
Text("Ses Medias :")
.font(.largeTitle)
.bold()
.padding(.leading)
ScrollView(.horizontal, showsIndicators: false){
HStack{
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
MediaListRow()
.frame(width: UIScreen.main.bounds.width/1.15)
.scaledToFit()
}
}
Text("Ses Articles :")
.font(.largeTitle)
.bold()
.padding(.leading)
ArticleListRow()
ArticleListRow()
ArticleListRow()
}
}.navigationBarTitle("Redactor")
}
// }//.padding(.top, -20)
}
}
I don't know what is the solution of this I hope it open normal but it don't find and I have the same with all scroll view. Please help me.
it is missing a .edgesIgnoringSafeArea(.top) on the navigationView which can give you the safeArea guard.
Related
I am trying to create a messaging page layout but the keyboard hides the textfield and moves everything to the the top. I have looked at many tutorials online and replicated them exactly but none of them seem to work.
Here is all the code I have written:
struct MessagingPage: View {
var user: OfficialUserModel
#ObservedObject private var vm = TheUserModel()
#State var screenWidth = UIScreen.main.bounds.width
#State var imageSize = UIScreen.main.bounds.width / 12
#State var text = ""
#State var show = false
#Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView{
ZStack{
VStack{
HStack{
Spacer()
NavigationLink(destination: UserDisplayPage(user: user)) {
HStack{
WebImage(url: URL(string: user.imageURL ))
.resizable()
.aspectRatio( contentMode: .fill)
.frame(width: imageSize, height: imageSize
)
.cornerRadius(imageSize/2)
VStack(alignment: .leading){
Text(user.FullName)
.font(.body)
.fontWeight(.bold)
.foregroundColor(.white)
Text("\(user.City) , \(user.Country)")
.font(.caption)
.fontWeight(.semibold)
.foregroundColor(.white)
}
}
}
Spacer()
HStack{
Button{
presentationMode.wrappedValue.dismiss()
} label: {
Image(systemName: "chevron.down")
.font(.title)
.foregroundColor(.myWhite)
}
}
.padding(.trailing)
}
.padding(.top, 30)
.frame(height: 75)
.background(Color.mainBlack)
ScrollView{
Spacer()
ForEach(0..<2){ num in
HStack{
Spacer()
HStack{
Text("Hello \(user.firstName)")
.foregroundColor(.orange)
}
.padding()
.background(Color.mainBlack)
.cornerRadius(15)
.shadow(color: .orange, radius: 2)
}
.padding(.horizontal)
.padding(.top, 8)
}
HStack{Spacer()}
HStack{
HStack{
Text("\(user.FullName) is unable to recieve your message at this time. Please try again at a later time.")
.foregroundColor(.green)
}
.padding()
.background(Color.mainBlack)
.cornerRadius(15)
.shadow(color: .green, radius: 2)
Spacer()
}
.padding(.horizontal)
.padding(.top, 8)
HStack{Spacer()}
}
.background(Color.mainBlack)
ZStack{
HStack{
HStack{
HStack{
TextField("Say Something...", text: self.$text)
.placeholder(when: text.isEmpty) {
Text("Say Something...").foregroundColor(.myWhite.opacity(0.5))
}
.frame(width: screenWidth - 200, height: screenWidth/25)
.foregroundColor(.myCyan)
.accentColor(.myCyan)
.background(Color.mainBlack)
.textContentType(.emailAddress)
if !text.isEmpty{
Button{
print(text)
self.text = ""
}label: {
Image(systemName: "paperplane")
.foregroundColor(.myCyan)
.font(.system(size: 20))
}
}
else{
Button{
print("Show more options")
}label: {
Image(systemName: "plus")
.foregroundColor(.myCyan)
.font(.system(size: 20))
}
}
}
.frame(width: screenWidth - 150, height: screenWidth/25)
.padding()
.background(Color.mainBlack)
.cornerRadius(30)
.shadow(color: .myCyan, radius: 5)
.padding(.bottom,5)
}
}
.padding(.bottom, 50)
.frame(width: screenWidth)
}
}
}
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
.background(Color.mainBlack)
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
}
I want the the textfield to move up as well as the messages in the scrollview but the top HStack with the user image and back/dismiss button should remain in place.
You really have a lot of code in there - and two reasons to clean it up:
To get a good answer, you need to post a minimal, reproducible example, which may also help you debug the code before posting it
Many lines of code are redundant or useless, for example:
Why using things like HStack{Spacer()} instead of Spacer(), which by the way is not needed in this context?
Why having a stack that has only another stack inside?
Coming to your issue, the problem is that one of the redundant modifiers is preventing the text file to move up, and this is the line to delete:
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
Why setting a frame that is as high and large as much as the screen? This is forcing the text field to stay at the bottom.
I tried to do some clean up, I bet some more can be done - see the code below, now the keyboard does not cover the text field anymore:
struct MessagingPage: View {
// Removed some lines of code to reproduce your issue
#State var screenWidth = UIScreen.main.bounds.width
#State var imageSize = UIScreen.main.bounds.width / 12
#State var text = ""
#State var show = false
#Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView{
// What is the purpose of this ZStack???
// ZStack{
VStack{
HStack{
Spacer()
NavigationLink(destination: Text("Hello")) {
Text("Top bar")
}
Spacer()
HStack{
Button{
presentationMode.wrappedValue.dismiss()
} label: {
Image(systemName: "chevron.down")
.font(.title)
.foregroundColor(.white)
}
}
.padding(.trailing)
}
.padding(.top, 30)
.frame(height: 75)
.background(Color.black)
ScrollView{
// All the views inside the Scrollview need to be inside a VStack
VStack {
// Why this spacer???
// Spacer()
ForEach(0..<2){ num in
HStack{
Spacer()
HStack{
Text("Hello username")
.foregroundColor(.orange)
}
.padding()
.background(Color.black)
.cornerRadius(15)
.shadow(color: .orange, radius: 2)
}
.padding(.horizontal)
.padding(.top, 8)
}
HStack{Spacer()}
HStack{
HStack{
Text("User is unable to receive your message at this time. Please try again at a later time.")
.foregroundColor(.green)
}
.padding()
.background(Color.black)
.cornerRadius(15)
.shadow(color: .green, radius: 2)
Spacer()
}
.padding(.horizontal)
.padding(.top, 8)
// Why a Spacer inside an HStack???
// HStack{Spacer()}
}
.background(Color.black)
}
// What is the purpose of this ZStack???
// ZStack{
// Why an HStack that has only an HStack inside??
// HStack{
// Why an HStack that has only an HStack inside??
// HStack{
HStack{
TextField("Say Something...", text: self.$text)
.frame(width: screenWidth - 200, height: screenWidth/25)
.foregroundColor(.cyan)
.accentColor(.cyan)
.background(Color.white)
.textContentType(.emailAddress)
if !text.isEmpty{
Button{
print(text)
self.text = ""
}label: {
Image(systemName: "paperplane")
.foregroundColor(.cyan)
.font(.system(size: 20))
}
}
else{
Button{
print("Show more options")
}label: {
Image(systemName: "plus")
.foregroundColor(.cyan)
.font(.system(size: 20))
}
}
}
// Are you sure you want set the height of this stack based on the width?
// .frame(width: screenWidth - 150, height: screenWidth/25)
.frame(width: screenWidth - 150)
.padding()
.background(Color.black)
.cornerRadius(30)
.shadow(color: .black, radius: 5)
.padding(.bottom,5)
// }
// }
.padding(.bottom, 50)
.frame(width: screenWidth)
// }
}
// }
// Why setting a frame that is high and large as much as the screen??
// .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
.background(Color.black)
.navigationBarTitle("")
.navigationBarHidden(true)
}
}
}
Disclaimer: New to SwiftUI
I know a ZStack() view allows me to overlap views, which is what I want for the heading section of the app.
I set the ZStack() to not take up the entire height and had expected an HStack(), placed after the ZStack() to do just that, appear after. Instead it also overlaps with the ZStack.
I'm sure it's a simple solution to co-exist. Image and code below.
var body: some View {
GeometryReader { geometry in
ZStack(alignment: .topLeading) {
Ellipse()
.fill(self.bgColor)
.frame(width: geometry.size.width * 1.4, height: geometry.size.height * 0.28)
.position(x: geometry.size.width / 2.35, y: geometry.size.height * 0.1)
.shadow(radius: 3)
.edgesIgnoringSafeArea(.all)
HStack(alignment: .top) {
VStack(alignment: .leading) {
Text(self.title)
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color.white)
Text(self.subtitle)
.font(.subheadline)
.fontWeight(.regular)
.foregroundColor(Color.white)
}
.padding(.leading, 25)
.padding(.top, 20)
Spacer()
VStack(alignment: .trailing) {
Image("SettingsIcon")
.resizable()
.scaledToFit()
.frame(width: 30, height: 30)
}
.padding(.top, 20)
.padding(.trailing, 25)
}
}
.fixedSize(horizontal: false, vertical: true)
HStack(alignment: .top) {
Text(self.title)
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color.white)
}
}
}
Try the following code using a top VStack and closing the GeometryReader before the last HStack:
var body: some View {
VStack { // <-- here
GeometryReader { geometry in
ZStack(alignment: .topLeading) {
Ellipse()
.fill(self.bgColor)
.frame(width: geometry.size.width * 1.4, height: geometry.size.height * 0.28)
.position(x: geometry.size.width / 2.35, y: geometry.size.height * 0.1)
.shadow(radius: 3)
.edgesIgnoringSafeArea(.all)
HStack(alignment: .top) {
VStack(alignment: .leading) {
Text(self.title)
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color.white)
Text(self.subtitle)
.font(.subheadline)
.fontWeight(.regular)
.foregroundColor(Color.white)
}
.padding(.leading, 25)
.padding(.top, 20)
Spacer()
VStack(alignment: .trailing) {
Image("SettingsIcon")
.resizable()
.scaledToFit()
.frame(width: 30, height: 30)
}
.padding(.top, 20)
.padding(.trailing, 25)
}
}.fixedSize(horizontal: false, vertical: true)
} // <-- here end GeometryReader
HStack(alignment: .top) {
Text(self.title)
.font(.title)
.fontWeight(.bold)
.foregroundColor(Color.white)
}
} // <-- here end VStack
}
I've managed to build a user form to get inputs and display them in grids. Right now I have them displayed in a scroll view. I'm avoiding lists so as to get a card like appearance. However, I'm not able to get a delete feature to work as it is done with Lists. I'm new to swift and not sure how to implement delete feature in this grid layout. I would like for users to be able to delete entries. I'm using Core Data, Swift and SwiftUI. Thanks.
struct ContentView: View {
// MARK: PROPERTIES
#Environment(\.managedObjectContext) var managedObjectContext
#State private var showingAddChangeView: Bool = false
#State private var dateAdded: Date = Date()
#State private var showingActionSheet = false
#FetchRequest(
entity: Agent.entity(),
sortDescriptors: [NSSortDescriptor(keyPath: \Agent.dateAdded, ascending: false)]) var cas: FetchedResults<Agent>
let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
return formatter
}()
private var gridItemLayout = [GridItem(.flexible())]
// MARK: BODY VIEW
var body: some View {
NavigationView {
ScrollView {
LazyVGrid(columns: gridItemLayout , alignment: .center, spacing: 30) {
ForEach(self.cas, id: \.self) { caRequest in
VStack(alignment: .leading) {
HStack {
Image(systemName: "calendar")
Text(caRequest.dateAdded ?? "Missing Dates")
.font(.callout).fontWeight(.bold)
Spacer()
Button(action: {
}) {
Image(systemName: "trash.fill")
.foregroundColor(.black)
}
.padding(.trailing, 20)
}
//.padding()
.padding(.leading, 20)
.padding(.top, 25)
Divider().frame(height: 1).background(Color.gray)
.padding()
HStack{
Image(systemName: "paintbrush.fill")
.foregroundColor(Color(.systemGreen))
.padding(.leading, 20)
.padding(.bottom, 5)
Text(caRequest.intention ?? "No Intentions Recorded")
.font(.callout).multilineTextAlignment(.leading)
.padding(.leading, 5)
.padding(.bottom, 5)
}
HStack{
Image(systemName: "checkmark.seal.fill")
.foregroundColor(Color(.systemBlue))
.padding(.leading, 20)
.padding(.bottom, 5)
Text(caRequest.affirmation ?? "No Affirmation Recorded")
.font(.callout).multilineTextAlignment(.leading)
.padding(.leading, 5)
.padding(.bottom, 5)
}
HStack{
Image(systemName: "heart.fill")
.foregroundColor(Color(.systemPink))
.padding(.leading, 20)
.padding(.bottom, 5)
Text(caRequest.gratitudeOne ?? "Missing Gratitude")
.font(.callout).multilineTextAlignment(.leading)
.padding(.leading, 5)
.padding(.bottom, 5)
}
HStack{
Image(systemName: "heart.fill")
.foregroundColor(Color(.systemPink))
.padding(.leading, 20)
.padding(.bottom, 5)
Text(caRequest.gratitudeTwo ?? "Missing Gratitude")
.font(.callout).multilineTextAlignment(.leading)
.padding(.leading, 5)
.padding(.bottom, 5)
}
HStack{
Image(systemName: "heart.fill")
.foregroundColor(Color(.systemPink))
.padding(.leading, 20)
.padding(.bottom, 20)
Text(caRequest.gratitudeThree ?? "Missing Gratitude")
.font(.callout).multilineTextAlignment(.leading)
.padding(.leading, 5)
.padding(.bottom, 20)
}
}
// .frame(width: 350, height: 300)
.frame(minWidth: 0, maxWidth: 350, minHeight: 0, maxHeight: .infinity)
} // END: FOR EACH
} // END: LAZYVGRID
} // END: SCROLLVIEW
.padding(.top, 100)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
HStack {
Image(systemName: "person.crop.square.fill")
.foregroundColor(.white)
.font(.title)
Text("Change Agent")
.foregroundColor(.white)
.font(.title2)
.fontWeight(.bold)
.shadow(radius: 20)
}
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(
trailing:
Button(action: {
self.showingAddChangeView.toggle()
}) {
Text("Add")
Image(systemName: "plus")
.imageScale(.medium)
} // END: ADD BUTTON
.foregroundColor(.white)
.sheet(isPresented: $showingAddChangeView) {
AddChangeView()
}
.navigationBarItems(trailing: EditButton())
) // END: NAVIGATION BAR ITEMS
} // END: NAVIGATIONVIEW
} // END: BODY VIEW
} // END: STRUCT
All
I'm new to iOS and SwiftUI (2 months). I'm struggling to understand the following behavior and hope someone can point me as to how I can diagnose.
I have this code successfully generating this view in the preview provider
however when I run it on a device or in the simulator the fonts change (happens for system images also) to look more like this (scaled up).
The view below is rendered inside of a very generic tabview - I cant fathom it at all and could use some guidance.
Thanks
Craig
var body: some View {
VStack(spacing: 0.0) {
HStack(alignment: .top){
Text(player.firstName)
.bold()
Text(player.lastName)
.bold()
}
.font(.title)
HStack {
Image(uiImage: UIImage(data: player.playerPhoto) ?? UIImage())
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: /*#START_MENU_TOKEN#*/100/*#END_MENU_TOKEN#*/, height: 100)
.clipShape(Circle())
.overlay(Circle().stroke(Color.purple, lineWidth: 4.0))
Spacer()
VStack {
Text("lifetime averages")
.font(.body)
.foregroundColor(Color.gray)
HStack {
Spacer()
VStack {
Text("Batting")
.font(.title2)
.bold()
Text("\(battingAverage, specifier: "%.3f")")
}
.padding(.leading)
if isPitcher {
Spacer()
VStack {
Text("ERA")
.font(.title2)
.bold()
Text("\(earnedRunAverage, specifier: "%.2f")")
}
.padding(.trailing)
Spacer()
}
}
}
Spacer()
}
HStack {
VStack {
Text("\(noTeams)")
.font(.headline)
Text("teams")
.font(.subheadline)
.foregroundColor(Color.gray)
}
.padding(.leading, 10)
Spacer()
VStack {
Text("\(noSeasons)")
.font(.headline)
Text("seasons")
.font(.subheadline)
.foregroundColor(Color.gray)
}
Spacer()
VStack {
Text("\(noGames)")
.font(.headline)
Text("games")
.font(.subheadline)
.foregroundColor(Color.gray)
}.padding(.trailing, 10)
}
HStack{
Spacer()
Text("All Lifetime Stats >")
.font(.callout)
.foregroundColor(Color.blue)
}
}
.frame(width: 350, height: 200, alignment: /*#START_MENU_TOKEN#*/.center/*#END_MENU_TOKEN#*/)
}
Your code does not specify a .font(...) for those two Text elements.
Is it possible you have set the default font somewhere else?
I can reproduce what you're getting by doing this (using PlayerView as a stand-alone view, not in a table).
If using UIKit App Delegate, in willConnectTo session:
let contentView = PlayerView()
.font(.largeTitle)
or, if using SwiftUI App:
#main
struct TestApp: App {
var body: some Scene {
WindowGroup {
PlayerView()
.font(.largeTitle)
}
}
}
I Have a button embedded inside a Hstack inside a Vstack inside a ZStack inside a Vstack inside a geometryReader in swiftui that does not get tapped. I put a print statement inside and whenever I tried to Tap the button, the print statement won't print. Can anyone help me out here? Thanks. Heres my code:
struct DetailedGroupView: View {
#State var actrualImage: Image?
#State var title = "title"
#State var description = "description"
#State var sgName = "sgName"
#State var membersCount = 0
#Environment(\.presentationMode) var presentationMode
var body: some View {
GeometryReader{ geo in
VStack{
ZStack{
(self.actrualImage ?? Image("earthPlaceholder"))
.resizable()
.aspectRatio(contentMode: .fill)
VStack{
Spacer()
HStack{
//This button doesn't work
Button(action: {
print("Button Tapped")
self.presentationMode.wrappedValue.dismiss()
}, label: {
Image(systemName: "chevron.left").foregroundColor(.white)
}).padding()
Text(self.title)
.font(.largeTitle)
.fontWeight(.bold)
.multilineTextAlignment(.leading)
.foregroundColor(.white)
.padding()
.minimumScaleFactor(0.5)
Spacer()
}
HStack{
Text(self.description)
.font(.custom("Open Sans", size: 18))
.fontWeight(.ultraLight)
.multilineTextAlignment(.leading)
.foregroundColor(.white)
.padding()
Spacer()
}
Spacer()
HStack{
Image(systemName: "person.2.fill").foregroundColor(.white).padding(.leading)
Text("\(self.membersCount)")
.font(.custom("Open Sans", size: 12))
.fontWeight(.semibold)
.foregroundColor(.white)
Spacer()
Text(self.sgName)
.font(.custom("Open Sans", size: 12))
.fontWeight(.semibold)
.foregroundColor(.white)
.padding()
}.padding()
}.frame(width: geo.size.width, height: 294)
}.frame(width: geo.size.width, height: 294)
.clipShape(RoundedRectangle(cornerRadius: 12))
.edgesIgnoringSafeArea(.top)
Spacer()
ScrollView(showsIndicators: false){
VStack{
Spacer()
}.onAppear{
self.actrualImage = Image("globePlaceholder")
}
}
}
}.navigationBarBackButtonHidden(true)
}
}
Just tested this same code on both XCode 11.5 and 12.0, and the button works fine... be sure to test it on a simulator not on the preview/canvas