Skip to content

Commit

Permalink
feat: Add features and UI update for notification #2813
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Sep 2, 2024
1 parent f429639 commit ad0251d
Show file tree
Hide file tree
Showing 18 changed files with 275 additions and 179 deletions.
Binary file added assets/icon/notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions lib/app/shared/constants/altme_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class AltMeStrings {

//page
static const String matrixChatSupportId = '@support:matrix.talao.co';
static const String matrixNotificationSupportId =
'@notification:matrix.talao.co';

//Chat
static const String dashBoardPage = '/dashboardPage';
Expand Down
1 change: 1 addition & 0 deletions lib/app/shared/constants/icon_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class IconStrings {
static const String home = '$base/empty-wallet.png';
static const String discover = '$base/discover.png';
static const String settings = '$base/settings.png';
static const String notification = '$base/notification.png';
static const String advanceSettings = '$base/advance-settings.png';
static const String export = '$base/export.png';
static const String copy = '$base/copy.png';
Expand Down
15 changes: 15 additions & 0 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,21 @@ String birthDateFormater(int birthData) {
return formattedBirthdate;
}

String chatTimeFormatter(int birthData) {
final String birthdate = birthData.toString();

// Parse the input string
final DateTime parsedBirthdate = DateTime.parse(
'${birthdate.substring(0, 4)}-${birthdate.substring(4, 6)}-${birthdate.substring(6, 8)}', // ignore: lines_longer_than_80_chars
);

// Format the parsed date
final DateFormat formatter = DateFormat('dd:MM:yyyy');
final String formattedBirthdate = formatter.format(parsedBirthdate);

return formattedBirthdate;
}

String getSignatureType(String circuitId) {
if (circuitId == 'credentialAtomicQuerySigV2' ||
circuitId == 'credentialAtomicQuerySigV2OnChain') {
Expand Down
8 changes: 5 additions & 3 deletions lib/chat_room/cubit/chat_room_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ abstract class ChatRoomCubit extends Cubit<ChatRoomState> {
);
}

setMessagesAsRead();

await Future<void>.delayed(const Duration(seconds: 1))
.then((val) => _getUnreadMessageCount());
}
Expand Down Expand Up @@ -289,7 +287,11 @@ abstract class ChatRoomCubit extends Cubit<ChatRoomState> {
final List<String> invites = [];

if (roomIdStoredKey == SecureStorageKeys.notificationSupportRoomId) {
invites.add(AltMeStrings.matrixNotificationSupportId);
if (helpCenterOptions.displayNotification != null &&
helpCenterOptions.displayNotification! &&
helpCenterOptions.customNotification != null) {
invites.add(helpCenterOptions.customNotification!);
}
} else {
//roomIdStoredKey == SecureStorageKeys.chatSupportRoomId
if (profileCubit.state.model.walletType == WalletType.enterprise &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';

class CryptoAccountSwitcherButton extends StatelessWidget {
const CryptoAccountSwitcherButton({
this.mainAxisAlignment = MainAxisAlignment.end,
super.key,
});

final MainAxisAlignment mainAxisAlignment;

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
Expand Down Expand Up @@ -44,7 +47,7 @@ class CryptoAccountSwitcherButton extends StatelessWidget {
);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: mainAxisAlignment,
children: [
if (blockchainType != null) ...[
Image.asset(
Expand Down
4 changes: 2 additions & 2 deletions lib/dashboard/profile/models/profile_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class HelpCenterOptions extends Equatable {
final bool displayChatSupport;
final bool displayEmailSupport;
final bool? displayNotification;
final bool? customNotification;
final String? customNotification;

Map<String, dynamic> toJson() => _$HelpCenterOptionsToJson(this);

Expand All @@ -484,7 +484,7 @@ class HelpCenterOptions extends Equatable {
bool? displayChatSupport,
bool? displayEmailSupport,
bool? displayNotification,
bool? customNotification,
String? customNotification,
}) =>
HelpCenterOptions(
customChatSupport: customChatSupport ?? this.customChatSupport,
Expand Down
115 changes: 68 additions & 47 deletions lib/dashboard/src/view/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,20 @@ class _DashboardViewState extends State<DashboardView> {

return BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, profileState) {
final displayChatSupport = profileState
.model.profileSetting.helpCenterOptions.displayChatSupport;
final profileModel = profileState.model;

final isEnterprise =
profileState.model.walletType == WalletType.enterprise;
profileModel.walletType == WalletType.enterprise;

final helpCenterOptions =
profileModel.profileSetting.helpCenterOptions;

final displayChatSupport = helpCenterOptions.displayChatSupport;

final displayNotification =
helpCenterOptions.displayNotification != null &&
helpCenterOptions.displayNotification! &&
helpCenterOptions.customNotification != null;

return PopScope(
canPop: false,
Expand All @@ -177,57 +186,69 @@ class _DashboardViewState extends State<DashboardView> {
},
child: BasePage(
scrollView: false,
title: _getTitle(dashboardState.selectedIndex, l10n),
scaffoldKey: scaffoldKey,
padding: EdgeInsets.zero,
drawer: const DrawerPage(),
titleLeading: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(
child: HomeTitleLeading(
onPressed: () {
if (context.read<HomeCubit>().state.homeStatus ==
HomeStatus.hasNoWallet) {
showDialog<void>(
context: context,
builder: (_) => const WalletDialog(),
);
return;
}
scaffoldKey.currentState!.openDrawer();
},
),
),
if (isEnterprise)
StreamBuilder(
initialData: context
.read<MatrixNotificationCubit>()
.unreadMessageCount,
stream: context
.read<MatrixNotificationCubit>()
.unreadMessageCountStream,
builder: (_, snapShot) {
return Flexible(
child: NotifyIcon(
badgeCount: snapShot.data ?? 0,
onTap: () {
Navigator.of(context)
.push<void>(NotificationPage.route());
},
),
);
},
),
],
),
titleTrailing: Parameters.walletHandlesCrypto
? const CryptoAccountSwitcherButton()
: const SizedBox.shrink(),
body: Stack(
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(10, 0, 15, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
HomeTitleLeading(
onPressed: () {
if (context
.read<HomeCubit>()
.state
.homeStatus ==
HomeStatus.hasNoWallet) {
showDialog<void>(
context: context,
builder: (_) => const WalletDialog(),
);
return;
}
scaffoldKey.currentState!.openDrawer();
},
),
if (Parameters.walletHandlesCrypto)
const CryptoAccountSwitcherButton(
mainAxisAlignment: MainAxisAlignment.center,
),
if (isEnterprise && displayNotification)
StreamBuilder(
initialData: context
.read<MatrixNotificationCubit>()
.unreadMessageCount,
stream: context
.read<MatrixNotificationCubit>()
.unreadMessageCountStream,
builder: (_, snapShot) {
return NotifyIcon(
badgeCount: snapShot.data ?? 0,
onTap: () {
Navigator.of(context).push<void>(
NotificationPage.route(),
);
},
);
},
),
],
),
),
Text(
_getTitle(dashboardState.selectedIndex, l10n),
maxLines: 2,
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.headlineSmall!
.copyWith(fontWeight: FontWeight.bold),
),
Expanded(
child: PageView(
controller: pageController,
Expand Down
5 changes: 4 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1062,5 +1062,8 @@
"etherlinkAccount": "Ethereum account",
"etherlinkAccountDescription": "Create a new Ethereum blockchain address",
"etherlinkAccountCreationCongratulations": "Your new Ethereum account has been successfully created.",
"etherlinkProofMessage": ""
"etherlinkProofMessage": "",
"notification": "Notification",
"notifications": "Notifications",
"notificationTitle": "Welcome to the Notifications!\nStay informed with important updates."
}
15 changes: 12 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"etherlinkAccount",
"etherlinkAccountDescription",
"etherlinkAccountCreationCongratulations",
"etherlinkProofMessage"
"etherlinkProofMessage",
"notification",
"notifications",
"notificationTitle"
],

"es": [
Expand Down Expand Up @@ -68,7 +71,10 @@
"etherlinkAccount",
"etherlinkAccountDescription",
"etherlinkAccountCreationCongratulations",
"etherlinkProofMessage"
"etherlinkProofMessage",
"notification",
"notifications",
"notificationTitle"
],

"fr": [
Expand Down Expand Up @@ -109,6 +115,9 @@
"etherlinkAccount",
"etherlinkAccountDescription",
"etherlinkAccountCreationCongratulations",
"etherlinkProofMessage"
"etherlinkProofMessage",
"notification",
"notifications",
"notificationTitle"
]
}
1 change: 1 addition & 0 deletions lib/matrix_notification/matrix_notification.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export 'cubit/matrix_notification_cubit.dart';
export 'view/notification_details_page.dart';
export 'view/notification_page.dart';
export 'widget/widget.dart';
42 changes: 42 additions & 0 deletions lib/matrix_notification/view/notification_details_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:altme/app/app.dart';
import 'package:altme/l10n/l10n.dart';

import 'package:flutter/material.dart';

class NotificationDetailsPage extends StatelessWidget {
const NotificationDetailsPage({
super.key,
required this.message,
});

final String message;

static Route<void> route({required String message}) {
return MaterialPageRoute<void>(
builder: (_) => NotificationDetailsPage(message: message),
settings: const RouteSettings(name: '/NotificationDetailsPage'),
);
}

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final colorScheme = Theme.of(context).colorScheme;
return BasePage(
title: l10n.notification,
scrollView: false,
titleLeading: const BackLeadingButton(),
titleAlignment: Alignment.topCenter,
padding: const EdgeInsets.all(Sizes.spaceSmall),
body: Text(
message,
style: TextStyle(
color: colorScheme.onSurface,
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1.5,
),
),
);
}
}
Loading

0 comments on commit ad0251d

Please sign in to comment.