Skip to content

Commit

Permalink
fix: 修复 navigationTitle 和 ColorPicker 不管用的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
thoamsy committed Nov 23, 2020
1 parent 67540b5 commit 2bbd8d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
9 changes: 7 additions & 2 deletions Shared/CategoriesList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ struct CategoriesList: View {
ProgressView()
} else {
List(categories, id: \.0) { (category, icons) in
NavigationLink(destination: ContentView(icons: icons, title: category), label: {
NavigationLink(
destination: ContentView(icons: icons)
.navigationBarTitle(category, displayMode: .inline),
label: {
Text(category)
})
}.navigationTitle("Symbols")
Expand All @@ -36,6 +39,8 @@ struct CategoriesList: View {

struct CategoriesList_Previews: PreviewProvider {
static var previews: some View {
CategoriesList()
Group {
CategoriesList()
}
}
}
27 changes: 18 additions & 9 deletions Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Combine

struct ContentView: View {
let icons: [String]
let title: String
@State private var tintColor: Color = .primary
@State var selectedIndex = -1

Expand All @@ -14,9 +13,7 @@ struct ContentView: View {
}

var body: some View {
print(tintColor)
return NavigationView {
ScrollView {
return ScrollView {
LazyVGrid(columns: columns) {
ForEach(Array(icons.enumerated()), id: \.1) { index, name in
VStack {
Expand All @@ -27,22 +24,34 @@ struct ContentView: View {
selectedIndex = index
}
.frame(width: 80, height: 80)
.cornerRadius(4)
.border(Color(UIColor.separator))
.cornerRadius(4)
.padding([.bottom], 4)
.contextMenu {
Text("Copy Symbol Name")
// Button(action: {
// UIPasteboard.general.string = name
// }, label: {
// Text("Copy Symbol Name")
// })
}

Text(name).foregroundColor(.primary).font(.footnote)
Text(name).foregroundColor(.primary).font(.footnote).lineLimit(2)
}
.frame(height: 120)

// .background(index == selectedIndex ? Color(UIColor.link) : Color(UIColor.secondarySystemGroupedBackground))
}
.font(.title2)
.padding()
}
}
.navigationTitle(title)
.navigationBarItems(trailing: ColorPicker("", selection: $tintColor, supportsOpacity: false))
}
.navigationBarItems(
trailing: VStack {
ColorPicker("", selection: $tintColor, supportsOpacity: false)
}
)
// }
}
}

Expand Down

0 comments on commit 2bbd8d1

Please sign in to comment.