Hi everyone,
sorry for this post, I already posted it but I can't find it anymore, I don't know why...
Anyway, here it is again.
I followed the tutorial from apple to create the Landmark app. I'm trying to go a little bit further.
This is a capture of what I would like to do:
Frame 3 will be a detailled vue of each beer. So it's a kind of menu in a menu.
This is the files I've got:
beerData.json
[
{
"id": 1,
"name": "Pilot",
"category": "Scottish beer",
"imageName": "Pilot",
"isSelected": true,
"beers": [
{
"name": "Mochaccino Stout",
"style": "Milk stout",
"abv": 5.5,
"id": 11,
"isFavorite": true,
"imageName": "Mochaccino_Stout",
"description": "Winner of the Bow Bar’s 2014 Dark Beer Challenge, Mochaccino Stout is a huge-bodied, full-flavoured milk stout, flavoured with coffee roast to our exact specifications, raw and roast organic cocoa nibs and Tahitian vanilla. A rich, comforting pint of luxury."
},
{
"name": "Blønd",
"style": "Oatmeal pale",
"abv": 4.0,
"id": 12,
"isFavorite": false,
"imageName": "Blond",
"description": "Cloudy like a wheat beer, Blønd is a (relatively) low ABV session pint that packs in all the body, bitterness and tropical fruit flavour of a much bigger beer."
},
{
"name": "Vienna Pale",
"style": "Vienna lager",
"abv": 4.6,
"id": 13,
"isFavorite": false,
"imageName": "Vienna_Pale",
"description": "Based on the classic Vienna Lager style (though technically an ale), and annoyer of a certain type of beer geek, Vienna Pale is a sweet, malty drinking pint, with plenty of Saaz, Citra and Cascade dry-hopping to keep things interesting."
}
]
},
{
"id": 2,
"name": "Fierce",
"category": "Scottish beer",
"imageName": "Fierce",
"isSelected": false,
"beers": [
{
"name": "Late Shift",
"style": "IPA",
"abv": 6.5,
"id": 21,
"isFavorite": false,
"imageName": "Late_Shift",
"description": "Late Shift is a crushable New England style IPA with low bitterness, a full on juicy profile and a lot of haze. We use Azacca and Citra hops for a tropical and citrus hop explosion."
}
]
},
{
"id": 3,
"name": "Parisis",
"category":"French beer",
"imageName":"Parisis",
"isSelected": false,
"beers": [
{
"name": "Blonde",
"style": "Pale ale",
"abv": 6.5,
"id": 21,
"isFavorite": false,
"imageName": "Blonde",
"description": "Bière blonde fruitée, aux notes houblonnées délicates. Un houblonnage a cru avec variétés spécifiques lui confèrent des arômes d'agrumes et de fruit tropicaux."
}
]
}
]I load this file like this in a specific file with the decode method (same as the one in the Landmark tutorial)
let beerData: [Beer] = load("beerData.json")So I manage to buid the Frame 1 like this:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach(breweryData) { brewery in
Text(brewery.name)
}
}
.navigationBarTitle(Text("Brewery"))
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}But I'm struggling to build the seconde frame.
My problem is how can I do the foreach only on beers from a specific brewery?
I hope I'm clear enough.
I stay available if you need more informations.
Thanks for your help.