Wednesday, October 28, 2026
HomeiOS Developmentios - View Not Increasing to Full Record Line Width- SwiftUI

ios – View Not Increasing to Full Record Line Width- SwiftUI

[ad_1]

I’ve Views embedded in an inventory, one View per Record merchandise however for some motive, the View solely takes up a small main a part of the record’s row, slightly than filling the total line. The embedded View is absolutely expanded within the preview of the View so I am uncertain why that is taking place.

Record View

import SwiftUI

struct AnnouncementsView: View{
    @Binding var bulletins: [Announcement]
    @State var displayedMessage: String = ""
    @State var isDisplayingMessage: Bool = false
    
    static let sectionDateFormat: DateFormatter = {
        let formatter = DateFormatter()
        formatter.dateFormat = "dd/MM/YYYY"
        return formatter
    }()
    var physique: some View{
        //NavigationView{
        VStack{
            Record($bulletins){$announcement in
                AnnouncementView(announcement: $announcement)
            }
            Spacer()
        }
    }
}

list view preview

Record Merchandise View

struct AnnouncementView: View{
    @Binding var announcement: Announcement
    @State non-public var sheetIsShowing: Bool = false
    static let sectionDateFormat: DateFormatter = {
        let formatter = DateFormatter()
        formatter.dateFormat = "dd/MM/YYYY"
        return formatter
    }()
    var physique: some View{
        HStack{
            Button(motion: {
                sheetIsShowing = true
            }){
                if (!announcement.learn){
                    Picture(systemName: "exclamationmark.circle.fill")
                        .foregroundColor(.purple)
                }
                Textual content(announcement.message)
                    .lineLimit(1)
                    .truncationMode(.tail)
                    .foregroundColor(.black)
                Spacer()
                Textual content("(announcement.timestamp, formatter: Self.sectionDateFormat)")
                    .disabled(true)
            }
        }
        .padding()
        .sheet(isPresented:$sheetIsShowing){
            NavigationView{
                DetailedAnnouncementView(announcement: $announcement)
                    .navigationTitle(Textual content("(announcement.timestamp, formatter: Self.sectionDateFormat)"))
                    .toolbar{
                        ToolbarItem(placement: .navigationBarLeading){
                            Button(motion: {
                                announcement.learn = true
                                sheetIsShowing = false
                            }){
                                Textual content("Mark as Learn")
                            }
                        }
                        ToolbarItem(placement: .navigationBarTrailing){
                            Button(motion: {
                                sheetIsShowing = false
                                announcement.learn = false
                            }){
                                Textual content("Mark as Unread")
                            }
                        }
                    }
            }
        }
    }
}

list item view preview

I am in all probability lacking one thing actually fundamental however any assist is way appreciated.

Thanks.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments