Advertisement
rifki_cs29

ProfilePage

Feb 12th, 2024
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 11.83 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:flutter_smmf_one/core/common/app_theme.dart';
  4. import 'package:flutter_smmf_one/core/widgets/custom_app_bar.dart';
  5. import 'package:flutter_smmf_one/core/widgets/custom_button.dart';
  6. import 'package:flutter_smmf_one/core/widgets/gap/gap.dart';
  7. import 'package:flutter_smmf_one/core/widgets/rotated_image.dart';
  8. import 'package:flutter_smmf_one/data/datasources/db/database_helper.dart';
  9. import 'package:flutter_smmf_one/presentation/controllers/home_controller.dart';
  10. import 'package:get/get.dart';
  11.  
  12. final _homeController = Get.put(HomeController(), permanent: true);
  13.  
  14. class ProfilePage extends StatelessWidget {
  15.   ProfilePage({super.key}) {
  16.     _homeController.getLoggedInUser();
  17.   }
  18.  
  19.   @override
  20.   Widget build(BuildContext context) {
  21.     return Scaffold(
  22.       appBar: const CustomAppBar(
  23.         titleText: 'Profile',
  24.       ),
  25.       body: SingleChildScrollView(
  26.         padding: EdgeInsets.symmetric(
  27.           horizontal: defaultMargin,
  28.         ),
  29.         child: Obx(() {
  30.           final loggedInUser = _homeController.loggedInUser;
  31.           if (loggedInUser[DatabaseHelper.columnID] != null) {
  32.             _homeController.getLatestAttendance(
  33.               loggedInUser[DatabaseHelper.columnID],
  34.             );
  35.           }
  36.  
  37.           final latestAttendance = _homeController.latestAttendance;
  38.  
  39.           return Column(
  40.             children: [
  41.               Gap(12.h),
  42.               Row(
  43.                 mainAxisAlignment: MainAxisAlignment.center,
  44.                 children: [
  45.                   RotatedImage(
  46.                     width: 150.w,
  47.                     height: 150.h,
  48.                     imagePath:
  49.                         loggedInUser[DatabaseHelper.columnPhotoMasterPath] ??
  50.                             '',
  51.                     mirrorHorizontal: true,
  52.                   ),
  53.                 ],
  54.               ),
  55.               Gap(20.h),
  56.               Row(
  57.                 mainAxisAlignment: MainAxisAlignment.center,
  58.                 children: [
  59.                   CustomButton.buttonRounded(
  60.                     onTap: () => Get.toNamed(
  61.                       '/edit-profile',
  62.                       arguments: {
  63.                         'phone': loggedInUser[DatabaseHelper.columnPhone] ?? '',
  64.                         'isEdit':
  65.                             loggedInUser[DatabaseHelper.columnProvinceName] !=
  66.                                     null
  67.                                 ? true
  68.                                 : false,
  69.                       },
  70.                     ),
  71.                     padding: EdgeInsets.symmetric(
  72.                       horizontal: 16.w,
  73.                       vertical: 8.h,
  74.                     ),
  75.                     text: 'Edit Profile',
  76.                   ),
  77.                   Gap(12.w),
  78.                   CustomButton.buttonRounded(
  79.                     onTap: () => Get.toNamed(
  80.                       '/register-photo',
  81.                       arguments: {
  82.                         'isRegister': false,
  83.                       },
  84.                     ),
  85.                     padding: EdgeInsets.symmetric(
  86.                       horizontal: 16.w,
  87.                       vertical: 8.h,
  88.                     ),
  89.                     text: 'Absence',
  90.                   ),
  91.                   Gap(12.w),
  92.                   CustomButton.buttonRounded(
  93.                     onTap: () => Get.toNamed(
  94.                       '/attendance-list',
  95.                       arguments: loggedInUser[DatabaseHelper.columnID],
  96.                     ),
  97.                     padding: EdgeInsets.symmetric(
  98.                       horizontal: 16.w,
  99.                       vertical: 8.h,
  100.                     ),
  101.                     text: 'Attendance',
  102.                   ),
  103.                 ],
  104.               ),
  105.               Gap(24.h),
  106.               Row(
  107.                 children: [
  108.                   Icon(
  109.                     Icons.phone,
  110.                     color: colorRed,
  111.                     size: 32.h,
  112.                   ),
  113.                   Gap(12.w),
  114.                   Column(
  115.                     crossAxisAlignment: CrossAxisAlignment.start,
  116.                     children: [
  117.                       Text(
  118.                         'Handphone',
  119.                         style: blackTextStyle.copyWith(
  120.                           fontSize: 12.sp,
  121.                           fontStyle: FontStyle.italic,
  122.                           fontWeight: semiBold,
  123.                         ),
  124.                       ),
  125.                       Gap(4.h),
  126.                       Text(
  127.                         loggedInUser[DatabaseHelper.columnPhone] ?? '',
  128.                         style: blackTextStyle.copyWith(
  129.                           fontSize: 12.sp,
  130.                         ),
  131.                       ),
  132.                     ],
  133.                   ),
  134.                 ],
  135.               ),
  136.               Gap(6.h),
  137.               Divider(
  138.                 thickness: 1.h,
  139.                 color: colorGrey,
  140.               ),
  141.               Gap(6.h),
  142.               Row(
  143.                 children: [
  144.                   Icon(
  145.                     Icons.group,
  146.                     color: colorRed,
  147.                     size: 32.h,
  148.                   ),
  149.                   Gap(12.w),
  150.                   Column(
  151.                     crossAxisAlignment: CrossAxisAlignment.start,
  152.                     children: [
  153.                       Text(
  154.                         'NIK',
  155.                         style: blackTextStyle.copyWith(
  156.                           fontSize: 12.sp,
  157.                           fontStyle: FontStyle.italic,
  158.                           fontWeight: semiBold,
  159.                         ),
  160.                       ),
  161.                       Gap(4.h),
  162.                       Text(
  163.                         loggedInUser[DatabaseHelper.columnNik] ?? '',
  164.                         style: blackTextStyle.copyWith(
  165.                           fontSize: 12.sp,
  166.                         ),
  167.                       ),
  168.                     ],
  169.                   ),
  170.                 ],
  171.               ),
  172.               Gap(6.h),
  173.               Divider(
  174.                 thickness: 1.h,
  175.                 color: colorGrey,
  176.               ),
  177.               Gap(6.h),
  178.               Row(
  179.                 children: [
  180.                   Icon(
  181.                     Icons.email,
  182.                     color: colorRed,
  183.                     size: 32.h,
  184.                   ),
  185.                   Gap(12.w),
  186.                   Column(
  187.                     crossAxisAlignment: CrossAxisAlignment.start,
  188.                     children: [
  189.                       Text(
  190.                         'Email',
  191.                         style: blackTextStyle.copyWith(
  192.                           fontSize: 12.sp,
  193.                           fontStyle: FontStyle.italic,
  194.                           fontWeight: semiBold,
  195.                         ),
  196.                       ),
  197.                       Gap(4.h),
  198.                       Text(
  199.                         loggedInUser[DatabaseHelper.columnEmail] ?? '',
  200.                         style: blackTextStyle.copyWith(
  201.                           fontSize: 12.sp,
  202.                         ),
  203.                       ),
  204.                     ],
  205.                   ),
  206.                 ],
  207.               ),
  208.               Gap(6.h),
  209.               Divider(
  210.                 thickness: 1.h,
  211.                 color: colorGrey,
  212.               ),
  213.               Gap(6.h),
  214.               Row(
  215.                 crossAxisAlignment: CrossAxisAlignment.start,
  216.                 children: [
  217.                   Icon(
  218.                     Icons.place,
  219.                     color: colorRed,
  220.                     size: 32.h,
  221.                   ),
  222.                   Gap(12.w),
  223.                   Column(
  224.                     crossAxisAlignment: CrossAxisAlignment.start,
  225.                     children: [
  226.                       Text(
  227.                         'Province',
  228.                         style: blackTextStyle.copyWith(
  229.                           fontSize: 12.sp,
  230.                           fontStyle: FontStyle.italic,
  231.                           fontWeight: semiBold,
  232.                         ),
  233.                       ),
  234.                       Gap(4.h),
  235.                       Text(
  236.                         loggedInUser[DatabaseHelper.columnProvinceName] ?? '-',
  237.                         style: blackTextStyle.copyWith(
  238.                           fontSize: 12.sp,
  239.                         ),
  240.                       ),
  241.                       Gap(8.h),
  242.                       Text(
  243.                         'City',
  244.                         style: blackTextStyle.copyWith(
  245.                           fontSize: 12.sp,
  246.                           fontStyle: FontStyle.italic,
  247.                           fontWeight: semiBold,
  248.                         ),
  249.                       ),
  250.                       Gap(4.h),
  251.                       Text(
  252.                         loggedInUser[DatabaseHelper.columnCityName] ?? '-',
  253.                         style: blackTextStyle.copyWith(
  254.                           fontSize: 12.sp,
  255.                         ),
  256.                       ),
  257.                       Gap(8.h),
  258.                       Text(
  259.                         'Sub District',
  260.                         style: blackTextStyle.copyWith(
  261.                           fontSize: 12.sp,
  262.                           fontStyle: FontStyle.italic,
  263.                           fontWeight: semiBold,
  264.                         ),
  265.                       ),
  266.                       Gap(4.h),
  267.                       Text(
  268.                         loggedInUser[DatabaseHelper.columnSubDistrictName] ??
  269.                             '-',
  270.                         style: blackTextStyle.copyWith(
  271.                           fontSize: 12.sp,
  272.                         ),
  273.                       ),
  274.                       Gap(8.h),
  275.                       Text(
  276.                         'District',
  277.                         style: blackTextStyle.copyWith(
  278.                           fontSize: 12.sp,
  279.                           fontStyle: FontStyle.italic,
  280.                           fontWeight: semiBold,
  281.                         ),
  282.                       ),
  283.                       Gap(4.h),
  284.                       Text(
  285.                         loggedInUser[DatabaseHelper.columnDistrictName] ?? '-',
  286.                         style: blackTextStyle.copyWith(
  287.                           fontSize: 12.sp,
  288.                         ),
  289.                       ),
  290.                       Gap(8.h),
  291.                       Text(
  292.                         'Longitude',
  293.                         style: blackTextStyle.copyWith(
  294.                           fontSize: 12.sp,
  295.                           fontStyle: FontStyle.italic,
  296.                           fontWeight: semiBold,
  297.                         ),
  298.                       ),
  299.                       Gap(4.h),
  300.                       Text(
  301.                         latestAttendance[DatabaseHelper.columnLongitude] ?? '-',
  302.                         style: blackTextStyle.copyWith(
  303.                           fontSize: 12.sp,
  304.                         ),
  305.                       ),
  306.                       Gap(8.h),
  307.                       Text(
  308.                         'Latitude',
  309.                         style: blackTextStyle.copyWith(
  310.                           fontSize: 12.sp,
  311.                           fontStyle: FontStyle.italic,
  312.                           fontWeight: semiBold,
  313.                         ),
  314.                       ),
  315.                       Gap(4.h),
  316.                       Text(
  317.                         latestAttendance[DatabaseHelper.columnLatitude] ?? '-',
  318.                         style: blackTextStyle.copyWith(
  319.                           fontSize: 12.sp,
  320.                         ),
  321.                       ),
  322.                     ],
  323.                   ),
  324.                 ],
  325.               ),
  326.             ],
  327.           );
  328.         }),
  329.       ),
  330.     );
  331.   }
  332. }
  333.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement