Configurable notification dots
Changelog-Added: Make notification dots configurable
This commit is contained in:
@@ -27,6 +27,12 @@ func timeline_bit(_ timeline: Timeline) -> Int {
|
||||
}
|
||||
}
|
||||
|
||||
func show_indicator(timeline: Timeline, current: NewEventsBits, indicator_setting: Int) -> Bool {
|
||||
if timeline == .notifications {
|
||||
return (current.rawValue & indicator_setting & NewEventsBits.notifications.rawValue) > 0
|
||||
}
|
||||
return (current.rawValue & indicator_setting) == timeline_to_notification_bits(timeline, ev: nil).rawValue
|
||||
}
|
||||
|
||||
struct TabButton: View {
|
||||
let timeline: Timeline
|
||||
@@ -35,13 +41,14 @@ struct TabButton: View {
|
||||
@Binding var new_events: NewEventsBits
|
||||
@Binding var isSidebarVisible: Bool
|
||||
|
||||
let settings: UserSettingsStore
|
||||
let action: (Timeline) -> ()
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .center) {
|
||||
Tab
|
||||
|
||||
if new_events.is_set(timeline) {
|
||||
if show_indicator(timeline: timeline, current: new_events, indicator_setting: settings.notification_indicators) {
|
||||
Circle()
|
||||
.size(CGSize(width: 8, height: 8))
|
||||
.frame(width: 10, height: 10, alignment: .topTrailing)
|
||||
@@ -55,7 +62,8 @@ struct TabButton: View {
|
||||
var Tab: some View {
|
||||
Button(action: {
|
||||
action(timeline)
|
||||
new_events = NewEventsBits(prev: new_events, unsetting: timeline)
|
||||
let bits = timeline_to_notification_bits(timeline, ev: nil)
|
||||
new_events = NewEventsBits(rawValue: new_events.rawValue & ~bits.rawValue)
|
||||
isSidebarVisible = false
|
||||
}) {
|
||||
Label("", systemImage: selected == timeline ? "\(img).fill" : img)
|
||||
@@ -72,16 +80,17 @@ struct TabBar: View {
|
||||
@Binding var selected: Timeline?
|
||||
@Binding var isSidebarVisible: Bool
|
||||
|
||||
let settings: UserSettingsStore
|
||||
let action: (Timeline) -> ()
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Divider()
|
||||
HStack {
|
||||
TabButton(timeline: .home, img: "house", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, action: action).keyboardShortcut("1")
|
||||
TabButton(timeline: .dms, img: "bubble.left.and.bubble.right", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, action: action).keyboardShortcut("2")
|
||||
TabButton(timeline: .search, img: "magnifyingglass.circle", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, action: action).keyboardShortcut("3")
|
||||
TabButton(timeline: .notifications, img: "bell", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, action: action).keyboardShortcut("4")
|
||||
TabButton(timeline: .home, img: "house", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, settings: settings, action: action).keyboardShortcut("1")
|
||||
TabButton(timeline: .dms, img: "bubble.left.and.bubble.right", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, settings: settings, action: action).keyboardShortcut("2")
|
||||
TabButton(timeline: .search, img: "magnifyingglass.circle", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, settings: settings, action: action).keyboardShortcut("3")
|
||||
TabButton(timeline: .notifications, img: "bell", selected: $selected, new_events: $new_events, isSidebarVisible: $isSidebarVisible, settings: settings, action: action).keyboardShortcut("4")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user