Skip to content

Commit

Permalink
CategoryごとにList表示分けする
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyome22 committed Sep 12, 2023
1 parent e9b3940 commit b0e8248
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions Sources/EmojiPalette/EmojiPaletteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,40 @@ public struct EmojiPaletteView: View {

public var body: some View {
VStack(spacing: 0) {
ScrollViewReader { proxy in
if let emojiSet = emojiSets.first(where: { $0.category == selection }) {
List {
ForEach(emojiSets) { emojiSet in
Section {
LazyVGrid(columns: columns, spacing: 8) {
ForEach(emojiSet.emojis) { emoji in
Button {
selectedEmoji = emoji.character
} label: {
Text(emoji.character)
.font(.title)
}
.buttonStyle(.borderless)
Section {
LazyVGrid(columns: columns, spacing: 8) {
ForEach(emojiSet.emojis) { emoji in
Button {
selectedEmoji = emoji.character
} label: {
Text(emoji.character)
.font(.title)
}
.buttonStyle(.borderless)
}
} header: {
Text(emojiSet.category.label, bundle: .module)
.id(emojiSet.category)
}
.textCase(.none)
} header: {
Text(emojiSet.category.label, bundle: .module)
}
.textCase(.none)
}
.listStyle(.plain)
Divider()
HStack {
ForEach(EmojiCategory.allCases) { emojiCategory in
Image(systemName: emojiCategory.imageName)
.foregroundColor(selection == emojiCategory ? Color.accentColor : .secondary)
.frame(maxWidth: .infinity)
.onTapGesture {
selection = emojiCategory
withAnimation {
proxy.scrollTo(emojiCategory, anchor: UnitPoint.top)
}
}
}
.id(selection)
}
Divider()
HStack {
ForEach(EmojiCategory.allCases) { emojiCategory in
Image(systemName: emojiCategory.imageName)
.foregroundColor(selection == emojiCategory ? Color.accentColor : .secondary)
.frame(maxWidth: .infinity)
.onTapGesture {
selection = emojiCategory
}
}
.padding(8)
}
.padding(8)
}
.frame(width: 240, height: 320)
}
Expand Down

0 comments on commit b0e8248

Please sign in to comment.