smartfarming-mobile/agrilink_vocpro/lib/features/setting/view/setting_screen.dart

142 lines
5.4 KiB
Dart
Raw Normal View History

2024-10-01 07:44:18 +00:00
import 'package:agrilink_vocpro/core/constant/app_color.dart';
import 'package:agrilink_vocpro/core/constant/app_theme.dart';
import 'package:agrilink_vocpro/core/route/app_route.dart';
2024-10-16 07:25:33 +00:00
import 'package:agrilink_vocpro/core/state/result_state.dart';
import 'package:agrilink_vocpro/features/setting/provider/setting_provider.dart';
2024-10-01 07:44:18 +00:00
import 'package:bootstrap_icons/bootstrap_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
2024-10-01 07:44:18 +00:00
class SettingScreen extends StatelessWidget {
const SettingScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
2024-11-06 01:54:08 +00:00
title: Text('Pengaturan', style: AppTheme.labelMedium),
2024-10-01 07:44:18 +00:00
centerTitle: true,
backgroundColor: Colors.white,
scrolledUnderElevation: 0,
),
2024-10-16 07:25:33 +00:00
body: Consumer<SettingProvider>(builder: (context, provider, child) {
return SafeArea(
child: ListView(
padding: EdgeInsets.all(16.r),
children: [
Row(
children: [
const CircleAvatar(
radius: 30,
backgroundColor: AppColor.secondary,
child: Icon(BootstrapIcons.person_fill, color: Colors.white),
),
SizedBox(width: 8.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(provider.userFullName, style: AppTheme.labelMedium),
Text(provider.userEmail, style: AppTheme.labelSmall)
],
2024-10-16 07:25:33 +00:00
)
],
2024-10-01 07:44:18 +00:00
),
2024-10-16 07:25:33 +00:00
SizedBox(height: 16.h),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.r),
),
child: Column(
children: [
ListTile(
tileColor: Colors.white,
2024-11-06 01:54:08 +00:00
title: Text('Akun',
2024-10-16 07:25:33 +00:00
style: AppTheme.labelSmall
.copyWith(color: Colors.black87)),
leading: const Icon(BootstrapIcons.person),
trailing: Icon(
Icons.arrow_forward_ios,
size: 16.r,
),
2024-11-04 02:18:27 +00:00
onTap: () {
context.go(AppRoute.account);
},
2024-10-01 07:44:18 +00:00
),
2024-11-04 02:18:27 +00:00
// ListTile(
// tileColor: Colors.white,
// title: Text('Kebijakan & privasi',
// style: AppTheme.labelSmall
// .copyWith(color: Colors.black87)),
// leading: const Icon(BootstrapIcons.shield_check),
// trailing: Icon(
// Icons.arrow_forward_ios,
// size: 16.r,
// ),
// onTap: () {},
// ),
// ListTile(
// tileColor: Colors.white,
// title: Text('Syarat & ketentuan',
// style: AppTheme.labelSmall
// .copyWith(color: Colors.black87)),
// leading: const Icon(BootstrapIcons.file_text),
// trailing: Icon(
// Icons.arrow_forward_ios,
// size: 16.r,
// ),
// onTap: () {},
// ),
2024-10-16 07:25:33 +00:00
ListTile(
2024-10-01 07:44:18 +00:00
tileColor: Colors.white,
2024-11-06 01:54:08 +00:00
title: Text('Keluar',
2024-10-01 07:44:18 +00:00
style: AppTheme.labelSmall.copyWith(color: Colors.red)),
leading: const Icon(
BootstrapIcons.box_arrow_right,
color: Colors.red,
),
trailing: Icon(
Icons.arrow_forward_ios,
size: 16.r,
),
onTap: () {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Logout'),
content: Text('Apakah anda yakin ingin logout?'),
actions: [
TextButton(
child: Text('Batal'),
onPressed: () {
Navigator.pop(context);
},
),
TextButton(
child: Text('Ya'),
2024-10-16 07:25:33 +00:00
onPressed: () async {
await provider.logout();
if (context.mounted) {
if (provider.logoutState ==
ResultState.hasData) {
context.go(AppRoute.root);
}
}
},
),
],
),
);
2024-10-16 07:25:33 +00:00
},
),
],
),
2024-10-01 07:44:18 +00:00
),
2024-10-16 07:25:33 +00:00
],
));
}),
2024-10-01 07:44:18 +00:00
);
}
}