import 'package:flutter/material.dart'; import 'package:double_back_to_close_app/double_back_to_close_app.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import 'package:IQ/app/global/convert_to_ago.dart'; import 'package:IQ/app/global/global_snackbar.dart'; import 'package:IQ/app/global/static_informs.dart'; import 'package:IQ/app/global/text_widget.dart'; import 'package:IQ/app/modules/drawerSide/views/drawer_side_view.dart'; import 'package:IQ/app/modules/home/providers/user.dart'; import '../controllers/notifications_screen_controller.dart'; class NotificationsScreenView extends GetView { NotificationsScreenView({Key? key}) : super(key: key); final GlobalKey scaffoldKey = GlobalKey(); @override Widget build(BuildContext context) { var stackedContainer = Container( height: 250, decoration: BoxDecoration( color: brandColor, image: const DecorationImage( image: AssetImage('assets/background.png'), fit: BoxFit.fill, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox(height: MediaQuery.of(context).viewPadding.top), Container( margin: const EdgeInsets.symmetric( horizontal: 15, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: const EdgeInsets.only( top: 5, right: 15, ), child: Row( children: [ SvgPicture.asset( "assets/2/icon.svg", height: 20, width: 71.16, ), const SizedBox(width: 10), Image.asset("assets/logo.png"), ], ), ), const SizedBox(width: 10), Row( children: [ Text( user?.data?.firstname ?? ' . . . ', style: const TextStyle( fontSize: 20, color: Colors.white, fontWeight: FontWeight.normal, ), ), IconButton( onPressed: () { scaffoldKey.currentState?.openEndDrawer(); }, icon: const Icon( Icons.menu, color: Colors.white, size: 40, ), ), ], ), ], ), ), Container( margin: const EdgeInsets.only(top: 10), child: Align( alignment: Alignment.bottomCenter, child: Column( children: [ SvgPicture.asset( 'assets/notifications.svg', color: Colors.white, height: 60, width: 60, ), const SizedBox(height: 3), TextWidget( text: 'notifications'.tr, color: Colors.white, fontSize: 24, fontWeight: FontWeight.w300, textAlign: TextAlign.center, ), const SizedBox(height: 10), ], ), ), ) ], ), ); return Directionality( textDirection: defaultLocale == "en" ? TextDirection.rtl : TextDirection.ltr, child: Scaffold( backgroundColor: backgroundColor, drawerScrimColor: Colors.black.withOpacity(0.7), key: scaffoldKey, endDrawer: const DrawerSideView(), drawerEdgeDragWidth: widthSize(context), body: DoubleBackToCloseApp( snackBar: snackBar, child: GetBuilder( builder: (NotificationsScreenController notificationsScreenController) { return RefreshIndicator( onRefresh: controller.onRefresh, triggerMode: RefreshIndicatorTriggerMode.anywhere, backgroundColor: Colors.white, color: brandColor, child: notificationsScreenController.fetchNotifsData ? Stack( children: [ Container( margin: const EdgeInsets.only(top: 270), child: (controller.listOfNotifs?.isNotEmpty)! ? SingleChildScrollView( physics: const AlwaysScrollableScrollPhysics(), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: controller.listOfNotifs?.map( (e) { return Container( padding: const EdgeInsets.all(15), margin: const EdgeInsets.all(15), decoration: BoxDecoration( color: Colors.white, border: Border.all( color: borderColor, width: 2, ), borderRadius: BorderRadius.circular(20), ), child: Center( child: Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ Column( crossAxisAlignment: CrossAxisAlignment .end, children: [ TextWidget( text: e.subject, fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black, textAlign: TextAlign.right, ), const SizedBox( height: 10), TextWidget( text: e.message, fontSize: 18, textAlign: TextAlign.right, color: const Color( 0xff7A7A7A), // overflow: // TextOverflow.ellipsis, ), const SizedBox( height: 25), Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, crossAxisAlignment: CrossAxisAlignment .center, children: [ TextWidget( text: convertToAgo( DateTime.parse( e.createdAt ?? ''), ), color: brandColor, fontSize: 16, ), const TextWidget( text: '', color: Colors.grey, fontSize: 16, ), ], ), ], ), ], ), ), ); }, ).toList() as List)) : Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ TextWidget( text: 'empty_notifications'.tr, color: Colors.grey, fontSize: 24, fontWeight: FontWeight.w500, textAlign: TextAlign.center, ), const SizedBox(height: 15), InkWell( child: const Icon( Icons.refresh, color: Colors.grey, size: 50, ), onTap: controller.onRefresh, ), ], ), ), ), stackedContainer ], ) : Stack( children: [ Center( child: CircularProgressIndicator( color: brandColor, ), ), stackedContainer ], ), ); }, ), ), ), ); } }