Skip to content

Commit

Permalink
Apply suggestions from @MaxDesiatov
Browse files Browse the repository at this point in the history
Co-authored-by: Max Desiatov <max@desiatov.com>
  • Loading branch information
j-f1 and MaxDesiatov committed Jul 20, 2020
1 parent d5667c1 commit 73c9c3f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Sources/TokamakDemo/TokamakDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@

import TokamakShim

func title<V>(_ view: V, title: String) -> AnyView where V: View {
@ViewBuilder
func title<V>(_ view: V, title: String) -> some View where V: View {
if #available(OSX 10.16, iOS 14.0, *) {
return AnyView(view.navigationTitle(title))
view.navigationTitle(title)
} else {
#if !os(macOS)
return AnyView(view.navigationBarTitle(title))
view.navigationBarTitle(title)
#else
return AnyView(view)
view
#endif
}
}
}

struct NavItem: Identifiable {
var id: String
var destination: AnyView?

init<V>(_ id: String, destination: V) where V: View {
self.id = id
self.destination = title(destination.frame(minWidth: 300), title: id)
self.destination = AnyView(title(destination.frame(minWidth: 300), title: id))
}

init(unavailiable id: String) {
Expand All @@ -52,11 +54,12 @@ var outlineGroupDemo: NavItem {
}

#if !os(macOS)
var listDemo: AnyView {
@ViewBuilder
var listDemo: some View {
if #available(iOS 14.0, *) {
return AnyView(ListDemo().listStyle(InsetGroupedListStyle()))
ListDemo().listStyle(InsetGroupedListStyle())
} else {
return AnyView(ListDemo())
ListDemo()
}
}
#else
Expand Down

0 comments on commit 73c9c3f

Please sign in to comment.