Configurable notification dots
Changelog-Added: Make notification dots configurable
This commit is contained in:
@@ -12,6 +12,10 @@ enum NotificationFilterState: String {
|
||||
case zaps
|
||||
case replies
|
||||
|
||||
func is_other( item: NotificationItem) -> Bool {
|
||||
return item.is_zap == nil && item.is_reply == nil
|
||||
}
|
||||
|
||||
func filter(_ item: NotificationItem) -> Bool {
|
||||
switch self {
|
||||
case .all:
|
||||
@@ -27,16 +31,10 @@ enum NotificationFilterState: String {
|
||||
struct NotificationsView: View {
|
||||
let state: DamusState
|
||||
@ObservedObject var notifications: NotificationsModel
|
||||
@State var filter_state: NotificationFilterState
|
||||
@State var filter_state: NotificationFilterState = .all
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
init(state: DamusState, notifications: NotificationsModel) {
|
||||
self.state = state
|
||||
self._notifications = ObservedObject(initialValue: notifications)
|
||||
self._filter_state = State(initialValue: load_notification_filter_state(pubkey: state.pubkey))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
TabView(selection: $filter_state) {
|
||||
NotificationTab(NotificationFilterState.all)
|
||||
@@ -54,6 +52,9 @@ struct NotificationsView: View {
|
||||
.onChange(of: filter_state) { val in
|
||||
save_notification_filter_state(pubkey: state.pubkey, state: val)
|
||||
}
|
||||
.onAppear {
|
||||
self.filter_state = load_notification_filter_state(pubkey: state.pubkey)
|
||||
}
|
||||
.safeAreaInset(edge: .top, spacing: 0) {
|
||||
VStack(spacing: 0) {
|
||||
CustomPicker(selection: $filter_state, content: {
|
||||
@@ -107,7 +108,7 @@ struct NotificationsView: View {
|
||||
|
||||
struct NotificationsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NotificationsView(state: test_damus_state(), notifications: NotificationsModel())
|
||||
NotificationsView(state: test_damus_state(), notifications: NotificationsModel(), filter_state: NotificationFilterState.all)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user