make demo compilable on Xcode 11

This commit is contained in:
John Estropia
2020-08-27 09:50:12 +09:00
parent 8b3b947406
commit 1db91fcec3
2 changed files with 41 additions and 34 deletions

View File

@@ -44,9 +44,10 @@ extension Modern.PokedexDemo {
.id(pokemonDisplay) .id(pokemonDisplay)
} }
ZStack { ZStack {
{ () -> AnyView in
if let pokemonForm = pokemonForm { if let pokemonForm = pokemonForm {
return AnyView(
VStack(alignment: .leading) { VStack(alignment: .leading) {
HStack { HStack {
@@ -55,22 +56,23 @@ extension Modern.PokedexDemo {
} }
HStack { HStack {
self.view(for: pokemonForm.$pokemonType1) self.view(for: pokemonForm.$pokemonType1)
if let pokemonType2 = pokemonForm.$pokemonType2 { pokemonForm.$pokemonType2.map(self.view(for:))
self.view(for: pokemonType2)
}
Spacer() Spacer()
} }
Spacer() Spacer()
} }
)
} }
else { else {
return AnyView(
Text(pokedexEntry?.$id ?? "") Text(pokedexEntry?.$id ?? "")
.foregroundColor(Color(UIColor.placeholderText)) .foregroundColor(Color(UIColor.placeholderText))
.fontWeight(.heavy) .fontWeight(.heavy)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
)
} }
}()
} }
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
} }

View File

@@ -20,20 +20,25 @@ struct NetworkImageView: View {
// MARK: View // MARK: View
var body: some View { var body: some View {
if let image = self.imageDownloader.image { if let image = self.imageDownloader.image {
return AnyView(
Image(uiImage: image) Image(uiImage: image)
.resizable() .resizable()
.aspectRatio(contentMode: .fit) .aspectRatio(contentMode: .fit)
)
} }
else { else {
return AnyView(
Circle() Circle()
.colorMultiply(Color(UIColor.placeholderText)) .colorMultiply(Color(UIColor.placeholderText))
.onAppear { .onAppear {
self.imageDownloader.fetchImage() self.imageDownloader.fetchImage()
} }
)
} }
} }