Merged with Majd

main_design2.0
zaid_daoud 2 years ago
parent e20f3b5433
commit dd524bcbd1

@ -12,7 +12,6 @@ import 'package:test_sa/new_views/pages/splash_page.dart';
import 'controllers/providers/api/user_provider.dart';
import 'controllers/providers/settings/setting_provider.dart';
import 'new_views/common_widgets/test screen.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
@ -62,9 +61,8 @@ class MyApp extends StatelessWidget {
],
supportedLocales: const [Locale('en'), Locale('ar')],
locale: Locale(settingProvider.language ?? 'en'),
initialRoute: TestScreen.id,
initialRoute: SplashPage.routeName,
routes: {
TestScreen.id: (_) => const TestScreen(),
SplashPage.routeName: (_) => const SplashPage(),
LoginPage.routeName: (_) => const LoginPage(),
LandPage.routeName: (_) => const LandPage(),

@ -2,14 +2,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:test_sa/new_views/common_widgets/app_bar/user_image.dart';
import '../../../models/user.dart';
import '../../app_style/app_color.dart';
import 'notification_icon.dart';
class HomeAppBar extends StatefulWidget implements PreferredSizeWidget{
int notificationCount;
String userImage;
HomeAppBar({Key key, this.notificationCount}) : super(key: key);
class HomeAppBar extends StatefulWidget implements PreferredSizeWidget {
final int notificationCount;
final String userImage;
const HomeAppBar({Key key, this.notificationCount, this.userImage}) : super(key: key);
@override
State<HomeAppBar> createState() => _AppBarState();
@ -25,26 +23,29 @@ class _AppBarState extends State<HomeAppBar> {
padding: const EdgeInsets.only(top: 30.0, right: 12, left: 12),
child: PreferredSize(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
UserImage(url: widget.userImage,),
NotificationIcon(notificationCount: 3,)
],
),
// SizedBox(height: 15),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text("welcome," , style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w500, color: AppColor.neutral20)),
// Text("Engineer name" , style: Theme.of(context).textTheme.headlineMedium?.copyWith(fontWeight: FontWeight.w600)),
// ],
// )
],
),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
UserImage(
url: widget.userImage,
),
NotificationIcon(
notificationCount: 3,
)
],
),
// SizedBox(height: 15),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text("welcome," , style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w500, color: AppColor.neutral20)),
// Text("Engineer name" , style: Theme.of(context).textTheme.headlineMedium?.copyWith(fontWeight: FontWeight.w600)),
// ],
// )
],
),
),
);
}

@ -2,18 +2,18 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:test_sa/extensions/context_extension.dart';
import '../../../models/enums/translation_keys.dart';
import '../../app_style/app_color.dart';
import '../../models/enums/translation_keys.dart';
import '../app_style/app_color.dart';
class HomeBottomNavigationBar extends StatefulWidget {
final Function(int index) onPressed;
const HomeBottomNavigationBar({Key key, @required this.onPressed}) : super(key: key);
class AppBottomNavigationBar extends StatefulWidget {
final Function(int index) onPressed;
const AppBottomNavigationBar({Key key, @required this.onPressed}) : super(key: key);
@override
State<HomeBottomNavigationBar> createState() => _HomeBottomNavigationBarState();
State<AppBottomNavigationBar> createState() => _AppBottomNavigationBarState();
}
class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
class _AppBottomNavigationBarState extends State<AppBottomNavigationBar> {
int _selectedIndex = 0;
void _onItemTapped(int index) {
@ -27,31 +27,27 @@ class _HomeBottomNavigationBarState extends State<HomeBottomNavigationBar> {
Widget build(BuildContext context) {
return Material(
elevation: 20,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
child: SizedBox(
height: 100,
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
child: BottomNavigationBar(
items: <BottomNavigationBarItem>[
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/images/Overview.svg', width: 24, height: 24,
color: _selectedIndex == 0? AppColor.primary70:AppColor.neutral20),
icon: SvgPicture.asset('assets/images/Overview.svg', width: 24, height: 24, color: _selectedIndex == 0 ? AppColor.primary70 : AppColor.neutral20),
label: context.translate(TranslationKeys.overview),
),
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/images/requests.svg', width: 24, height: 24,
color: _selectedIndex == 1? AppColor.primary70:AppColor.neutral20),
icon: SvgPicture.asset('assets/images/requests.svg', width: 24, height: 24, color: _selectedIndex == 1 ? AppColor.primary70 : AppColor.neutral20),
label: context.translate(TranslationKeys.myRequest),
),
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/images/assets.svg',width: 24, height: 24,
color: _selectedIndex == 2? AppColor.primary70:AppColor.neutral20),
icon: SvgPicture.asset('assets/images/assets.svg', width: 24, height: 24, color: _selectedIndex == 2 ? AppColor.primary70 : AppColor.neutral20),
label: context.translate(TranslationKeys.myRequest),
),
BottomNavigationBarItem(
icon: SvgPicture.asset('assets/images/message.svg', width: 24, height: 24,
color: _selectedIndex == 3? AppColor.primary70:AppColor.neutral20),
icon: SvgPicture.asset('assets/images/message.svg', width: 24, height: 24, color: _selectedIndex == 3 ? AppColor.primary70 : AppColor.neutral20),
label: context.translate(TranslationKeys.contactUs),
),
],

@ -21,6 +21,7 @@ class AppDrawer extends StatelessWidget {
AppFilledButton(
label: TranslationKeys.login,
onPressed: () async {
/// TODO [zaid] : show dialog before logout
// bool result = await showDialog(
// context: context,
// builder: (_) => const AAlertDialog(

@ -3,15 +3,16 @@ import 'package:test_sa/extensions/context_extension.dart';
import '../app_style/app_color.dart';
class AddFloatingButton extends StatelessWidget {
class AppFloatingButton extends StatelessWidget {
final IconData icon;
final VoidCallback onPressed;
const AddFloatingButton({Key key, @required this.onPressed}) : super(key: key);
const AppFloatingButton({Key key, @required this.icon, @required this.onPressed}) : super(key: key);
@override
Widget build(BuildContext context) {
return FloatingActionButton(
onPressed: onPressed,
child: Icon(Icons.add , color: context.isDark? AppColor.neutral50:AppColor.neutral30, ),
child: Icon(icon, color: context.isDark ? AppColor.neutral50 : AppColor.neutral30),
);
}
}

@ -1,46 +0,0 @@
import 'package:flutter/material.dart';
import 'package:test_sa/new_views/common_widgets/app_bar/custom_app_bar.dart';
import 'add_floating_button.dart';
import 'app_bar/home_app_bar.dart';
import 'bottom_nav_bar/home_bottom_nav_bar.dart';
class TestScreen extends StatefulWidget {
static const String id = '/test';
const TestScreen({Key key}) : super(key: key);
@override
State<TestScreen> createState() => _TestScreenState();
}
class _TestScreenState extends State<TestScreen> {
int screenIndex =0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: HomeAppBar(),
body: Center(child: _widgetOptions[screenIndex]),
floatingActionButton: AddFloatingButton(onPressed: () {},),
bottomNavigationBar: HomeBottomNavigationBar(onPressed: (index){
setState(() {
screenIndex = index;
});
},),
);
}
static const List<Widget> _widgetOptions = <Widget>[
Text(
'Index 0',
),
Text(
'Index 1',
),
Text(
'Index 2',
),
Text(
'Index 3',
),
];
}

@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'dashboard_page_indicator.dart';
class DashboardPage extends StatefulWidget {
const DashboardPage({Key key}) : super(key: key);
@override
State<DashboardPage> createState() => _DashboardPageState();
}
class _DashboardPageState extends State<DashboardPage> {
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 Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
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'),
),
],
),
),
],
);
}
}

@ -2,12 +2,13 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/new_views/common_widgets/app_bar/home_app_bar.dart';
import '../../common_widgets/app_bottom_nav_bar.dart';
import '../../common_widgets/app_drawer.dart';
import 'dashboard_page_indicator.dart';
import '../../common_widgets/app_floating_button.dart';
import 'dashboard_page.dart';
class LandPage extends StatefulWidget {
static const String routeName = "/land-page";
@ -18,29 +19,19 @@ class LandPage extends StatefulWidget {
}
class _LandPageState extends State<LandPage> {
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();
}
int currentPageIndex = 0;
static const List<Widget> _pages = <Widget>[
DashboardPage(),
Text('Index 1'),
Text('Index 2'),
Text('Index 3'),
];
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
/// TODO [zaid] : show dialog before exit
// bool result = await showDialog(
// context: context,
// builder: (_) => const AAlertDialog(
@ -58,54 +49,23 @@ class _LandPageState extends State<LandPage> {
return false;
},
child: Scaffold(
appBar: AppBar(),
appBar: HomeAppBar(),
body: Padding(
padding: EdgeInsets.only(left: 16.toScreenWidth, top: 11.toScreenHeight),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
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'),
),
],
),
),
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(icon: Icon(Icons.add), label: "add"),
BottomNavigationBarItem(icon: Icon(Icons.add), label: "add"),
BottomNavigationBarItem(icon: Icon(Icons.add), label: "add"),
],
child: _pages[currentPageIndex],
),
drawer: const AppDrawer(),
floatingActionButton: AppFloatingButton(
icon: Icons.add,
onPressed: () {},
),
bottomNavigationBar: AppBottomNavigationBar(
onPressed: (index) {
setState(() {
currentPageIndex = index;
});
},
),
),
);
}

Loading…
Cancel
Save