import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/text_extensions.dart'; import 'package:test_sa/extensions/widget_extensions.dart'; import 'package:test_sa/models/enums/translation_keys.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_drawer.dart'; import 'package:test_sa/new_views/common_widgets/app_floating_action_button.dart'; import 'dashboard_page_indicator.dart'; class DashboardPage extends StatefulWidget { final VoidCallback onDrawerPress; const DashboardPage({Key key, this.onDrawerPress}) : super(key: key); @override State createState() => _DashboardPageState(); } class _DashboardPageState extends State { PageController _controller; int _currentPage = 1; @override void initState() { super.initState(); _controller = PageController() ..addListener(() { _currentPage = _controller.page.toInt() + 1; setState(() {}); }); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: const AppFloatingActionButton(), appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: const Color(0xffF8F9FB), titleSpacing: 0, title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( width: 48, height: 48, decoration: const ShapeDecoration( image: DecorationImage( image: NetworkImage( "https://www.shutterstock.com/shutterstock/photos/1714666150/display_1500/stock-photo-head-shot-portrait-close-up-smiling-confident-businessman-wearing-glasses-looking-at-camera-1714666150.jpg"), fit: BoxFit.cover, ), shape: OvalBorder( side: BorderSide(width: 1, color: Color(0xFFE4E5E6)), ), ), ).onPress(widget.onDrawerPress), Stack( alignment: Alignment.topRight, children: [ const Icon( Icons.notifications, color: Color(0xff767676), size: 30, ).paddingOnly(top: 6, end: 0), Positioned( top: 0, right: 0, child: Container( padding: const EdgeInsets.all(4), decoration: const ShapeDecoration( color: Color(0xFFD02127), shape: CircleBorder(), ), child: Text("3", style: AppTextStyles.bodyText), ), ) ], ), ], ).paddingOnly(start: 16, end: 16), ), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( context.translation.welcome, style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral20), ), Text( "Eng Mahmoud", style: AppTextStyles.heading2.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50, fontWeight: FontWeight.w600), ), 24.height, Row( children: [ DashboardPageIndicator(index: 0, currentPage: _currentPage, controller: _controller), 3.width, DashboardPageIndicator(index: 1, currentPage: _currentPage, controller: _controller), 3.width, DashboardPageIndicator(index: 2, currentPage: _currentPage, controller: _controller), 10.width, Text( "0$_currentPage/03", style: Theme.of(context).textTheme.labelMedium?.copyWith(fontWeight: FontWeight.w500), ), ], ), 8.height, Expanded( child: PageView( controller: _controller, children: const [ Center( child: Text('First Page'), ), Center( child: Text('Second Page'), ), Center( child: Text('Third Page'), ), ], ), ), ], ).paddingAll(16), ); } }