You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
248 lines
7.4 KiB
Dart
248 lines
7.4 KiB
Dart
import 'package:car_provider_app/api/shared_prefrence.dart';
|
|
import 'package:car_provider_app/config/routes.dart';
|
|
import 'package:car_provider_app/theme/colors.dart';
|
|
import 'package:car_provider_app/utils/navigator.dart';
|
|
import 'package:car_provider_app/widgets/app_bar.dart';
|
|
import 'package:car_provider_app/widgets/show_fill_button.dart';
|
|
import 'package:car_provider_app/extensions/int_extensions.dart';
|
|
import 'package:car_provider_app/extensions/string_extensions.dart';
|
|
import 'package:car_provider_app/extensions/widget_extensions.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:image_picker/image_picker.dart';
|
|
import 'dart:io';
|
|
|
|
class DashboardPage extends StatefulWidget {
|
|
@override
|
|
State<DashboardPage> createState() => _DashboardPageState();
|
|
}
|
|
|
|
enum ImageSourceType { gallery, camera }
|
|
|
|
class _DashboardPageState extends State<DashboardPage> {
|
|
String userName = "";
|
|
|
|
// void _handleURLButtonPress(BuildContext context, var type) {
|
|
// Navigator.push(context,
|
|
// MaterialPageRoute(builder: (context) => ImageFromGalleryEx(type)));
|
|
// }
|
|
|
|
File? imagePicked;
|
|
final _picker = ImagePicker();
|
|
|
|
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
fetchUsername();
|
|
}
|
|
|
|
fetchUsername() async {
|
|
userName = await SharedPrefManager.getPhoneOrEmail();
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: appBar(
|
|
title: "Logo/Brand",
|
|
),
|
|
drawer: showDrawer(context),
|
|
body: Container(
|
|
child: Container(
|
|
child: Center(
|
|
child: "Dashboard/Main Page".toText24(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget showDrawer(BuildContext context) {
|
|
return Drawer(
|
|
child: Container(
|
|
child: Column(
|
|
children: [
|
|
Stack(
|
|
children:[
|
|
Container(
|
|
width: double.infinity,
|
|
height: 200,
|
|
color: accentColor.withOpacity(0.3),
|
|
child: Icon(
|
|
Icons.person,
|
|
size: 80,
|
|
color: accentColor.withOpacity(0.3),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 10,
|
|
right: 10,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
width: 40,
|
|
height: 40,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[200],
|
|
borderRadius: BorderRadius.circular(30),
|
|
),
|
|
child: Icon(Icons.edit,
|
|
color: Colors.blue,).onPress(() {
|
|
_openImagePicker();
|
|
// _handleURLButtonPress(context, ImageSourceType.camera);
|
|
}),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
] ),
|
|
// Container(
|
|
// width: double.infinity,
|
|
// height: 200,
|
|
// color: accentColor.withOpacity(0.3),
|
|
// child: Icon(
|
|
// Icons.person,
|
|
// size: 80,
|
|
// color: accentColor.withOpacity(0.3),
|
|
// ),
|
|
// ),
|
|
Container(
|
|
width: double.infinity,
|
|
color: accentColor.withOpacity(0.1),
|
|
padding: EdgeInsets.all(20),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
userName.toText24(),
|
|
"User role or title".toText12(),
|
|
],
|
|
),
|
|
),
|
|
ShowFillButton(
|
|
title: "EDIT",
|
|
onPressed: () {},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_notification.svg"),
|
|
title: "Notifications".toText12(),
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_settings.svg"),
|
|
title: "General".toText12(),
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_notes.svg"),
|
|
title: "Define Licenses".toText12(),
|
|
onTap: (){
|
|
navigateWithName(context, AppRoutes.defineLicense);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_car.svg"),
|
|
title: "Dealership Settings".toText12(),
|
|
onTap: (){
|
|
navigateWithName(context, AppRoutes.dealershipSetting);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_lock.svg"),
|
|
title: "Change Password".toText12(),
|
|
onTap: (){
|
|
navigateWithName(context, AppRoutes.changePassword);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_mobile.svg"),
|
|
title: "Change Mobile".toText12(),
|
|
),
|
|
ListTile(
|
|
leading: SvgPicture.asset("assets/images/ic_logout.svg"),
|
|
title: "Sign Out".toText12(),
|
|
onTap: () {
|
|
pop(context);
|
|
pop(context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// Implementing the image picker
|
|
// Future<void> _openImagePicker() async {
|
|
// final XFile? pickedImage =
|
|
// await _picker.pickImage(source: ImageSource.gallery);
|
|
// if (pickedImage != null) {
|
|
// setState(() {
|
|
// // _image = File(pickedImage.path);
|
|
// });
|
|
// }
|
|
// }
|
|
|
|
void _openImagePicker() {
|
|
showDialog<ImageSource>(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
content: Text("Choose image source"),
|
|
actions: [
|
|
FlatButton(
|
|
child: Text("Camera"),
|
|
onPressed: () =>
|
|
cameraImage()
|
|
),
|
|
FlatButton(
|
|
child: Text("Gallery"),
|
|
onPressed: () => gallaryImage()
|
|
),
|
|
]
|
|
),
|
|
// .then((ImageSource source) async {
|
|
// if (source != null) {
|
|
// final pickedFile = await ImagePicker().getImage(source: source);
|
|
// setState(() => imagePicked = File(pickedFile.path));
|
|
// }
|
|
// }
|
|
);
|
|
}
|
|
|
|
void gallaryImage() async {
|
|
final picker = ImagePicker();
|
|
final pickedImage = await picker.pickImage(
|
|
source: ImageSource.gallery,
|
|
);
|
|
final pickedImageFile = File(pickedImage!.path);
|
|
setState(() {
|
|
imagePicked = pickedImageFile;
|
|
});
|
|
}
|
|
|
|
void cameraImage() async {
|
|
final picker = ImagePicker();
|
|
final pickedImage = await picker.pickImage(
|
|
source: ImageSource.camera,
|
|
);
|
|
final pickedImageFile = File(pickedImage!.path);
|
|
setState(() {
|
|
imagePicked = pickedImageFile;
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|