in Education by
I'm trying to recreate the same view as the Carrot Weather Layout modifier, that is a carousel on top of a button that, when pressed, would open the detail view of the item currently displayed. What would be your approach to achieving that? I've tried using onTapesture and onDragGesture to store the value attached to the item but that doesn't seem to be working. Thanks for the help! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
One way might be to use the selection property of a TabView, and tag each of the views inside the TabView with a .tag(index) where index is an int. You can then use a State variable bound to the selection property to know which view was selected. import SwiftUI struct SwiftUIView: View { @State var tabSelected = 0 @State var weatherText = "is..." var body: some View { VStack { Spacer() Text("Weather: \(weatherText)") .font(.largeTitle) .bold() Spacer() TabView (selection: $tabSelected) { // Add each of the carousel views, e.g.images // First view in carousel Image(systemName:"sun.max") .resizable() .scaledToFit() .tag(1) // Second view in carousel Image(systemName:"cloud.rain") .resizable() .scaledToFit() .tag(2) } .tabViewStyle(PageTabViewStyle(indexDisplayMode: .automatic)) .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always)) Spacer() Button("GET WEATHER..") { if(tabSelected == 1) { weatherText = "It's sunny" } else if(tabSelected == 2) { weatherText = "It's raining" } } Spacer() } } }

Related questions

0 votes
    I'm trying to recreate the same view as the Carrot Weather Layout modifier, that is a carousel on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    When transaction Ti requests a data item currently held by Tj, Ti is allowed to wait only if it ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    When transaction Ti requests a data item currently held by Tj, Ti is allowed to wait only if it ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    Thanks for helping. I am trying to develop a static carousel (it won't move, but it acts like one) that stretches ... screen (but hidden, so no scrollbar). Here is the markup:...
asked Feb 19, 2022 in Education by JackTerrance
+1 vote
    How to find the index of an item in a list in Python?...
asked Jan 9, 2021 in Technology by JackTerrance
0 votes
    How can someone get a index (1) in Python for a list ["qwe", "asd", "zxc"] and an item "asd" in the list? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    What does stack overflow' refer to? a. accessing item from an undefined stack b. index out of bounds exception ... from an empty stack Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    What does stack overflow' refer to? a. accessing item from an undefined stack b. index out of bounds exception ... from an empty stack Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    How to get the UserID of all the currently logged in users using Apex code?...
asked Nov 11, 2020 in Technology by JackTerrance
0 votes
    I am trying to create a combobox in a datagrid. So far I have the two versions of this combobox ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I am trying to create a combobox in a datagrid. So far I have the two versions of this combobox ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    In runtime, I want to retrieve the expire time info about some items in memcached. I didn't find ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    How to get a particular item in the Model in Django?...
asked Jul 2, 2021 in Technology by JackTerrance
0 votes
    How will you get the min valued item of a list in Python?...
asked Nov 26, 2020 in Technology by JackTerrance
0 votes
    How will you get the max valued item of a list Python?...
asked Nov 26, 2020 in Technology by JackTerrance
...