From 5b94690d02d5f524f92c221ae35b8ca8c9285463 Mon Sep 17 00:00:00 2001 From: pahmiudahgede Date: Sat, 17 May 2025 00:11:44 +0700 Subject: [PATCH] feat: add view of profile page (uncompleted yet) --- lib/core/utils/exportimportview.dart | 2 +- lib/core/utils/navigation.dart | 2 +- lib/features/profil/components/clip_path.dart | 39 +++++++ .../profil/components/logout_button.dart | 56 ++++++++++ .../profil/components/profile_list_tile.dart | 46 ++++++++ .../components/profile_menu_option.dart | 51 +++++++++ .../presentation/screen/profil_screen.dart | 105 ++++++++++++++++++ lib/features/profil/profil_screen.dart | 62 ----------- 8 files changed, 299 insertions(+), 64 deletions(-) create mode 100644 lib/features/profil/components/clip_path.dart create mode 100644 lib/features/profil/components/logout_button.dart create mode 100644 lib/features/profil/components/profile_list_tile.dart create mode 100644 lib/features/profil/components/profile_menu_option.dart create mode 100644 lib/features/profil/presentation/screen/profil_screen.dart delete mode 100644 lib/features/profil/profil_screen.dart diff --git a/lib/core/utils/exportimportview.dart b/lib/core/utils/exportimportview.dart index 130256f..3938584 100644 --- a/lib/core/utils/exportimportview.dart +++ b/lib/core/utils/exportimportview.dart @@ -3,7 +3,7 @@ export 'package:rijig_mobile/core/utils/navigation.dart'; export 'package:rijig_mobile/features/activity/activity_screen.dart'; export 'package:rijig_mobile/features/cart/cart_screen.dart'; export 'package:rijig_mobile/features/home/presentation/screen/home_screen.dart'; -export 'package:rijig_mobile/features/profil/profil_screen.dart'; +export 'package:rijig_mobile/features/profil/presentation/screen/profil_screen.dart'; export 'package:rijig_mobile/features/requestpick/presentation/screen/requestpickup_screen.dart'; export 'package:rijig_mobile/features/auth/presentation/screen/inputpin_screen.dart'; export 'package:rijig_mobile/features/auth/presentation/screen/login_screen.dart'; diff --git a/lib/core/utils/navigation.dart b/lib/core/utils/navigation.dart index 3c17bcf..c336201 100644 --- a/lib/core/utils/navigation.dart +++ b/lib/core/utils/navigation.dart @@ -5,7 +5,7 @@ import 'package:rijig_mobile/core/router.dart'; import 'package:rijig_mobile/features/activity/activity_screen.dart'; import 'package:rijig_mobile/features/cart/cart_screen.dart'; import 'package:rijig_mobile/features/home/presentation/screen/home_screen.dart'; -import 'package:rijig_mobile/features/profil/profil_screen.dart'; +import 'package:rijig_mobile/features/profil/presentation/screen/profil_screen.dart'; import 'package:shared_preferences/shared_preferences.dart'; class NavigationPage extends StatefulWidget { diff --git a/lib/features/profil/components/clip_path.dart b/lib/features/profil/components/clip_path.dart new file mode 100644 index 0000000..89976d1 --- /dev/null +++ b/lib/features/profil/components/clip_path.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; + +class ClipInfoClass extends CustomClipper { + @override + Path getClip(Size size) { + Path path = Path(); + path.lineTo(0, size.height); + path.lineTo(size.width - 80, size.height); + path.lineTo(size.width, size.height - 80); + path.lineTo(size.width, 0); + path.close(); + + return path; + } + + @override + bool shouldReclip(covariant CustomClipper oldClipper) => false; +} + +class ClipPathClass extends CustomClipper { + @override + Path getClip(Size size) { + Path path = Path(); + path.lineTo(0, size.height - 60); + path.quadraticBezierTo( + size.width / 2, + size.height, + size.width, + size.height - 60, + ); + path.lineTo(size.width, 0); + path.close(); + + return path; + } + + @override + bool shouldReclip(covariant CustomClipper oldClipper) => false; +} diff --git a/lib/features/profil/components/logout_button.dart b/lib/features/profil/components/logout_button.dart new file mode 100644 index 0000000..cf10570 --- /dev/null +++ b/lib/features/profil/components/logout_button.dart @@ -0,0 +1,56 @@ +// ignore_for_file: use_build_context_synchronously + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:rijig_mobile/core/router.dart'; +import 'package:rijig_mobile/core/utils/guide.dart'; +import 'package:rijig_mobile/features/auth/presentation/viewmodel/logout_vmod.dart'; +import 'package:rijig_mobile/widget/buttoncard.dart'; + +class ButtonLogout extends StatefulWidget { + const ButtonLogout({super.key}); + + @override + State createState() => _ButtonLogoutState(); +} + +class _ButtonLogoutState extends State { + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, viewModel, child) { + return Column( + children: [ + CardButtonOne( + textButton: viewModel.isLoading ? 'Logging out...' : 'Logout', + fontSized: 16, + colorText: whiteColor, + color: redColor, + borderRadius: 10, + horizontal: double.infinity, + vertical: 50, + onTap: () async { + await viewModel.logout(); + + if (viewModel.errorMessage == null) { + router.go("/login"); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(viewModel.errorMessage!)), + ); + } + }, + loadingTrue: viewModel.isLoading, + usingRow: false, + ), + if (viewModel.errorMessage != null) + Text( + viewModel.errorMessage!, + style: TextStyle(color: Colors.red), + ), + ], + ); + }, + ); + } +} diff --git a/lib/features/profil/components/profile_list_tile.dart b/lib/features/profil/components/profile_list_tile.dart new file mode 100644 index 0000000..5bdc7db --- /dev/null +++ b/lib/features/profil/components/profile_list_tile.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:iconsax_flutter/iconsax_flutter.dart'; + +class ProfileListTile extends StatelessWidget { + const ProfileListTile({ + super.key, + required this.onTap, + required this.icon, + required this.iconColor, + required this.title, + }); + + final void Function() onTap; + final IconData icon; + final Color iconColor; + final String title; + + @override + Widget build(BuildContext context) { + return Material( + color: Colors.transparent, + child: InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(10), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + Icon(icon, color: iconColor), + const SizedBox(width: 16), + Text( + title, + style: Theme.of( + context, + ).textTheme.bodyLarge?.copyWith(color: Colors.black), + ), + const Spacer(), + + Icon(Iconsax.arrow_right_3_copy), + ], + ), + ), + ), + ); + } +} diff --git a/lib/features/profil/components/profile_menu_option.dart b/lib/features/profil/components/profile_menu_option.dart new file mode 100644 index 0000000..3bf93e4 --- /dev/null +++ b/lib/features/profil/components/profile_menu_option.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:iconsax_flutter/iconsax_flutter.dart'; +import 'package:rijig_mobile/core/utils/guide.dart'; +import 'package:rijig_mobile/features/profil/components/profile_list_tile.dart'; + +class ProfileMenuOptions extends StatelessWidget { + const ProfileMenuOptions({super.key}); + + @override + Widget build(BuildContext context) { + return Container( + padding: PaddingCustom().paddingAll(7), + decoration: BoxDecoration( + color: whiteColor, + border: Border.all(color: greyColor), + borderRadius: BorderRadius.circular(20), + ), + child: Column( + children: [ + ProfileListTile( + title: 'Ubah Pin', + iconColor: primaryColor, + icon: Iconsax.wallet, + onTap: () {}, + ), + Divider(thickness: 0.7, color: greyColor), + ProfileListTile( + title: 'Alamat', + iconColor: primaryColor, + icon: Iconsax.wallet, + onTap: () {}, + ), + Divider(thickness: 0.7, color: greyColor), + ProfileListTile( + title: 'Bantuan', + icon: Iconsax.wallet, + iconColor: primaryColor, + onTap: () {}, + ), + Divider(thickness: 0.7, color: greyColor), + ProfileListTile( + title: 'Ulasan', + icon: Iconsax.wallet, + iconColor: primaryColor, + onTap: () {}, + ), + ], + ), + ); + } +} diff --git a/lib/features/profil/presentation/screen/profil_screen.dart b/lib/features/profil/presentation/screen/profil_screen.dart new file mode 100644 index 0000000..e0b0df4 --- /dev/null +++ b/lib/features/profil/presentation/screen/profil_screen.dart @@ -0,0 +1,105 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:rijig_mobile/core/utils/guide.dart'; +import 'package:rijig_mobile/features/profil/components/clip_path.dart'; +import 'package:rijig_mobile/features/profil/components/logout_button.dart'; +import 'package:rijig_mobile/features/profil/components/profile_menu_option.dart'; + +class ProfilScreen extends StatefulWidget { + const ProfilScreen({super.key}); + + @override + State createState() => _ProfilScreenState(); +} + +class _ProfilScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Stack( + children: [ + ClipPath( + clipper: ClipPathClass(), + child: Container( + height: 180, + width: MediaQuery.of(context).size.width, + color: primaryColor, + ), + ), + Positioned( + top: 60, + left: 20, + right: 20, + child: Container( + padding: EdgeInsets.all(20), + decoration: BoxDecoration( + color: whiteColor, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: Colors.grey.withValues(alpha: 0.3), + spreadRadius: 1, + blurRadius: 8, + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Fahmi Kurniawan'), + SizedBox(height: 10), + Text('+62878774527342'), + SizedBox(height: 20), + + // Row( + // children: [ + // Text( + // 'Tipe Kontributor: ', + // style: TextStyle(fontWeight: FontWeight.bold), + // ), + // Chip( + // label: Text('Personal'), + // backgroundColor: Colors.green, + // labelStyle: TextStyle(color: Colors.white), + // ), + // ], + // ), + // SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Tervalidasi', + style: TextStyle(color: Colors.green), + ), + Text('edit', style: TextStyle(color: Colors.blue)), + ], + ), + ], + ), + ), + ), + + SingleChildScrollView( + child: Container( + margin: EdgeInsets.only(top: 245), + child: Padding( + padding: PaddingCustom().paddingHorizontal(20), + child: Column( + children: [ + ProfileMenuOptions(), + // SizedBox(height: 20), + Gap(30), + ButtonLogout(), + ], + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/features/profil/profil_screen.dart b/lib/features/profil/profil_screen.dart deleted file mode 100644 index a36173e..0000000 --- a/lib/features/profil/profil_screen.dart +++ /dev/null @@ -1,62 +0,0 @@ -// ignore_for_file: use_build_context_synchronously - -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:rijig_mobile/core/router.dart'; -import 'package:rijig_mobile/features/auth/presentation/viewmodel/logout_vmod.dart'; -import 'package:rijig_mobile/widget/buttoncard.dart'; - -class ProfilScreen extends StatefulWidget { - const ProfilScreen({super.key}); - - @override - State createState() => _ProfilScreenState(); -} - -class _ProfilScreenState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Consumer( - builder: (context, viewModel, child) { - return Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text("Are you sure you want to logout?"), - SizedBox(height: 20), - CardButtonOne( - textButton: viewModel.isLoading ? 'Logging out...' : 'Logout', - fontSized: 16, - colorText: Colors.white, - borderRadius: 10, - horizontal: double.infinity, - vertical: 50, - onTap: () async { - await viewModel.logout(); - - if (viewModel.errorMessage == null) { - router.go("/login"); - } else { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(viewModel.errorMessage!)), - ); - } - }, - loadingTrue: viewModel.isLoading, - usingRow: false, - ), - if (viewModel.errorMessage != null) - Text( - viewModel.errorMessage!, - style: TextStyle(color: Colors.red), - ), - ], - ), - ); - }, - ), - ); - } -}