1

I am just finishing up an iOS/watchOS app. After upgrading my watch to WatchOS8 I discovered a new glitch that was not present with WatchOS7. I have a list of regions each containing some locations and a link in each cell of the list to navigate to a list of these locations. In OS8 I find that the first time I tap a region name it navigates properly to the location list, but after that it does not. Rather it seems to store the link so that when I tab to another screen (TripView or ExcursionView in the code below) it briefly navigates to the correct location list then immediately back to the region list (not to TripView or ExcursionView). Here is the relevant part of the code.

struct ContentView: View {
    var body: some View {
        TabView {
            WatchCurrentView()
            WatchTripView(tripType:.trip)
            WatchTripView(tripType:.interval)
            WatchRegionView()
            WatchExcursionView()
        }
    }
}
struct WatchRegionView: View {
    @FetchRequest(fetchRequest:Region.fetch())
    var regions: FetchedResults<Region>
    var body: some View {
        VStack{
        Spacer()
            .frame(height:5)
        List{ForEach(regions, id:\.self){region in
            ZStack(alignment: Alignment(horizontal: .leading, vertical: .center)) {
                RegionCell(region:region)
                    .frame(height:14)
                NavigationLink(
                    destination: WatchLocationsInRegionView(region:region),
                    label: {
                        EmptyView()
                    }
                )
            }
        }
        .environment(\.defaultMinListRowHeight, 0.1)
        Spacer()
        }
        .navigationBarTitle("Regions")
        }
    }
}
struct RegionCell:View {
    @EnvironmentObject var prefs: Prefs
    var region:Region
    var body: some View {
        HStack{
            Spacer()
                .frame(width:15)
            Text(region.name)
            Spacer()
        }
        .frame(height:25)
        .background(Color(prefs.colorTheme.navBarFG))
        .foregroundColor(Color(prefs.colorTheme.navBarBG))
    }
}

struct WatchLocationsInRegionView:View {
    @State var region:Region
    var body: some View {
        List{ForEach(region.locations, id:\.self)
            {location in
            ZStack{
            WatchLocationView (aLocation: InternalLocation(location: location), tripType:.trip,locationType: .list)
            NavigationLink(
                destination: BigWatchLocationView(aLocation: InternalLocation(location: location)),
                label: {
                    EmptyView()
                })
            }
        }
        .font(.system(size: 14))
        .navigationBarTitle("\(region.name)")
        .onAppear(){prefs.watchDisplayMode = .coordinates}
        }
    }
}
PGHinman
  • 11
  • 1
  • 3

0 Answers0