stack_wallet/lib/notifications/notification_card.dart

98 lines
3.2 KiB
Dart
Raw Normal View History

2022-08-26 08:11:35 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/models/notification_model.dart';
import 'package:stackwallet/utilities/format.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/widgets/rounded_container.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class NotificationCard extends StatelessWidget {
const NotificationCard({
Key? key,
required this.notification,
}) : super(key: key);
final NotificationModel notification;
String extractPrettyDateString(DateTime date) {
// TODO: format this differently to better match the design
return Format.extractDateFrom(date.millisecondsSinceEpoch ~/ 1000);
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
RoundedWhiteContainer(
child: Row(
children: [
notification.changeNowId == null
? SvgPicture.asset(
notification.iconAssetName,
width: 24,
height: 24,
)
: Container(
width: 24,
height: 24,
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(24),
),
child: SvgPicture.asset(
notification.iconAssetName,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
2022-08-26 08:11:35 +00:00
width: 24,
height: 24,
),
),
const SizedBox(
width: 12,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
notification.title,
2022-09-22 22:17:21 +00:00
style: STextStyles.titleBold12(context),
2022-08-26 08:11:35 +00:00
),
const SizedBox(
height: 2,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
notification.description,
2022-09-22 22:17:21 +00:00
style: STextStyles.label(context),
2022-08-26 08:11:35 +00:00
),
Text(
extractPrettyDateString(notification.date),
2022-09-22 22:17:21 +00:00
style: STextStyles.label(context),
2022-08-26 08:11:35 +00:00
),
],
),
],
),
),
],
),
),
if (notification.read)
Positioned.fill(
child: RoundedContainer(
color: Theme.of(context)
.extension<StackColors>()!
.background
.withOpacity(0.5),
2022-08-26 08:11:35 +00:00
),
),
],
);
}
}