kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix favourite spelling on notification enum
rodzic
0f4ecd8676
commit
9ff185d553
|
@ -1,8 +1,10 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../routes.dart';
|
||||
import '../services/notifications_manager.dart';
|
||||
|
||||
enum NavBarButtons {
|
||||
timelines,
|
||||
|
@ -19,6 +21,8 @@ class AppBottomNavBar extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final notificationManager = context.watch<NotificationsManager>();
|
||||
final hasNotifications = notificationManager.notifications.isNotEmpty;
|
||||
return BottomNavigationBar(
|
||||
onTap: (index) {
|
||||
final newButton = _indexToButton(index);
|
||||
|
@ -51,7 +55,7 @@ class AppBottomNavBar extends StatelessWidget {
|
|||
selectedItemColor: Colors.black,
|
||||
unselectedItemColor: Colors.black54,
|
||||
currentIndex: _buttonToIndex(currentButton),
|
||||
items: _menuItems,
|
||||
items: _menuItems(hasNotifications),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -94,29 +98,33 @@ class AppBottomNavBar extends StatelessWidget {
|
|||
throw ArgumentError('$index has no button type');
|
||||
}
|
||||
|
||||
List<BottomNavigationBarItem> get _menuItems {
|
||||
return const [
|
||||
BottomNavigationBarItem(
|
||||
List<BottomNavigationBarItem> _menuItems(bool hasNotifications) {
|
||||
return [
|
||||
const BottomNavigationBarItem(
|
||||
label: 'Timelines',
|
||||
icon: Icon(Icons.home_outlined),
|
||||
activeIcon: Icon(Icons.home_filled),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Notifications',
|
||||
icon: Icon(Icons.notifications_none_outlined),
|
||||
activeIcon: Icon(Icons.notifications),
|
||||
icon: Icon(hasNotifications
|
||||
? Icons.notifications_active_outlined
|
||||
: Icons.notifications_none_outlined),
|
||||
activeIcon: Icon(hasNotifications
|
||||
? Icons.notifications_active
|
||||
: Icons.notifications),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
const BottomNavigationBarItem(
|
||||
label: 'Messages',
|
||||
icon: Icon(Icons.messenger_outline),
|
||||
activeIcon: Icon(Icons.messenger),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
const BottomNavigationBarItem(
|
||||
label: 'Contacts',
|
||||
icon: Icon(Icons.people_outline),
|
||||
activeIcon: Icon(Icons.people_sharp),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
const BottomNavigationBarItem(
|
||||
label: 'Profile',
|
||||
icon: Icon(Icons.person_outline),
|
||||
activeIcon: Icon(Icons.person),
|
||||
|
|
|
@ -61,7 +61,7 @@ class NotificationControl extends StatelessWidget {
|
|||
case NotificationType.unknown:
|
||||
buildSnackbar(context, 'Unknown message type, nothing to do');
|
||||
break;
|
||||
case NotificationType.favorite:
|
||||
case NotificationType.favourite:
|
||||
case NotificationType.mention:
|
||||
case NotificationType.reshare:
|
||||
case NotificationType.status:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
enum NotificationType {
|
||||
favorite,
|
||||
favourite,
|
||||
follow,
|
||||
follow_request,
|
||||
mention,
|
||||
|
@ -7,6 +7,25 @@ enum NotificationType {
|
|||
status,
|
||||
unknown;
|
||||
|
||||
String toVerb() {
|
||||
switch (this) {
|
||||
case NotificationType.favourite:
|
||||
return 'favorited';
|
||||
case NotificationType.follow:
|
||||
return 'follows';
|
||||
case NotificationType.follow_request:
|
||||
return 'sent follow request to you';
|
||||
case NotificationType.mention:
|
||||
return 'mentioned you on';
|
||||
case NotificationType.reshare:
|
||||
return 'reshared';
|
||||
case NotificationType.status:
|
||||
return 'updated';
|
||||
case NotificationType.unknown:
|
||||
return 'unknowned';
|
||||
}
|
||||
}
|
||||
|
||||
static NotificationType parse(String? text) {
|
||||
if (text == null) {
|
||||
return unknown;
|
||||
|
|
|
@ -37,7 +37,10 @@ class NotificationsScreen extends StatelessWidget {
|
|||
return NotificationControl(notification: notifications[index]);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Divider();
|
||||
return Divider(
|
||||
color: Colors.black54,
|
||||
height: 0.0,
|
||||
);
|
||||
},
|
||||
itemCount: notifications.length);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ extension NotificationMastodonExtension on UserNotification {
|
|||
case NotificationType.unknown:
|
||||
content = '${from.name} has unknown interaction notification';
|
||||
break;
|
||||
case NotificationType.favorite:
|
||||
case NotificationType.favourite:
|
||||
case NotificationType.mention:
|
||||
case NotificationType.reshare:
|
||||
case NotificationType.status:
|
||||
|
@ -47,7 +47,7 @@ extension NotificationMastodonExtension on UserNotification {
|
|||
statusLink = status.externalLink;
|
||||
final referenceType = status.parentId.isEmpty ? 'post' : 'comment';
|
||||
content =
|
||||
"${from.name} $type on ${status.author}'s $referenceType: ${status.body.truncate()}";
|
||||
"${from.name} ${type.toVerb()} ${status.author}'s $referenceType: ${status.body.truncate()}";
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue