From 25df88bb80448ed38b8ecf4901ae666e4abca034 Mon Sep 17 00:00:00 2001 From: Moe Date: Fri, 22 Sep 2023 14:29:07 +0700 Subject: [PATCH] Sync all source code with the latest flutter SDK and dependencies --- .gitlab-ci.yml | 2 +- .metadata | 34 ++-- lib/api/api.dart | 2 +- lib/components/about_us_body.dart | 16 +- lib/components/bannerimage.dart | 2 +- lib/components/checkout_form.dart | 18 +- lib/components/checkout_items.dart | 14 +- lib/components/color_dot.dart | 2 +- lib/components/forgot_pass_body.dart | 63 ++++--- lib/components/login_form.dart | 10 +- lib/components/menu.dart | 12 +- lib/components/new_arrival_products.dart | 110 ++++++------ lib/components/newsletter.dart | 71 ++++---- lib/components/otp_body.dart | 27 ++- lib/components/payment_body.dart | 8 +- lib/components/popular_products.dart | 10 +- lib/components/product_card.dart | 15 +- lib/components/product_detail.dart | 6 +- lib/components/register_error.dart | 4 +- lib/components/register_form.dart | 8 +- lib/components/register_verify.dart | 4 +- lib/components/search_form.dart | 9 +- lib/components/search_page.dart | 78 +++++---- lib/components/section_title.dart | 2 +- lib/components/transaction_box.dart | 210 +++++++++++++---------- lib/data/auth.dart | 9 +- lib/main.dart | 12 +- lib/screens/about_us.dart | 2 +- lib/screens/cart.dart | 208 +++++++++++----------- lib/screens/checkout.dart | 8 +- lib/screens/faq.dart | 19 +- lib/screens/forgotpassword.dart | 2 +- lib/screens/home.dart | 20 +-- lib/screens/login.dart | 2 +- lib/screens/otp.dart | 6 +- lib/screens/payment.dart | 2 +- lib/screens/products.dart | 8 +- lib/screens/register.dart | 2 +- lib/screens/sessions.dart | 152 ++++++++-------- lib/screens/transactions.dart | 85 +++++---- lib/utils/navigation_auth.dart | 40 ++--- workspace.bat | 6 +- workspace.sh | 6 +- 43 files changed, 695 insertions(+), 631 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1fcb8da..9912b05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ android:release: before_script: - flutter create . - flutter pub get - - flutter pub run flutter_launcher_icons_maker:main + - flutter pub run flutter_launcher_icons - flutter clean script: - flutter doctor --android-licenses diff --git a/.metadata b/.metadata index 95f73f5..b41277d 100644 --- a/.metadata +++ b/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - channel: stable + revision: "367f9ea16bfae1ca451b9cc27c1366870b187ae2" + channel: "stable" project_type: app @@ -13,26 +13,26 @@ project_type: app migration: platforms: - platform: root - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: android - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: ios - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: linux - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: macos - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: web - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 - platform: windows - create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 - base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 + create_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 + base_revision: 367f9ea16bfae1ca451b9cc27c1366870b187ae2 # User provided section diff --git a/lib/api/api.dart b/lib/api/api.dart index 69221b9..42184d9 100644 --- a/lib/api/api.dart +++ b/lib/api/api.dart @@ -1,6 +1,6 @@ import 'package:dio/dio.dart'; -import 'package:nekoya_flutter/api/config.dart'; +import 'package:nekoya_app/api/config.dart'; Future getProducts() async { var req = await Dio().get('$host/getproducts'); diff --git a/lib/components/about_us_body.dart b/lib/components/about_us_body.dart index 38269d5..a118bc7 100644 --- a/lib/components/about_us_body.dart +++ b/lib/components/about_us_body.dart @@ -15,14 +15,14 @@ class _AboutUsBodyState extends State { @override void initState() { super.initState(); - _controller = - VideoPlayerController.network('https://nekoya.moe.team/img/AboutUs.mp4') - ..initialize().then((_) { - setState(() { - _controller.play(); - _controller.setLooping(true); - }); - }); + _controller = VideoPlayerController.networkUrl( + Uri.parse('https://nekoya.moe.team/img/AboutUs.mp4')) + ..initialize().then((_) { + setState(() { + _controller.play(); + _controller.setLooping(true); + }); + }); } @override diff --git a/lib/components/bannerimage.dart b/lib/components/bannerimage.dart index 13fa0f3..80ff44c 100644 --- a/lib/components/bannerimage.dart +++ b/lib/components/bannerimage.dart @@ -51,7 +51,7 @@ class Bannerimage extends StatelessWidget { Navigator.pushReplacementNamed(context, '/products'); }, style: ElevatedButton.styleFrom( - primary: Colors.red, + backgroundColor: Colors.red, textStyle: const TextStyle( fontSize: 14, fontWeight: FontWeight.bold)), child: const Text('SHOP NOW'), diff --git a/lib/components/checkout_form.dart b/lib/components/checkout_form.dart index 78ee076..3d90865 100644 --- a/lib/components/checkout_form.dart +++ b/lib/components/checkout_form.dart @@ -2,9 +2,9 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/data/auth.dart'; -import 'package:nekoya_flutter/data/cart.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/data/auth.dart'; +import 'package:nekoya_app/data/cart.dart'; class CheckoutForm extends StatefulWidget { const CheckoutForm({Key? key}) : super(key: key); @@ -102,8 +102,8 @@ class _CheckoutFormState extends State { const SizedBox( height: 20, ), - Row( - children: const [ + const Row( + children: [ Text( "Contact Information", style: TextStyle( @@ -131,8 +131,8 @@ class _CheckoutFormState extends State { const SizedBox( height: 20, ), - Row( - children: const [ + const Row( + children: [ Text( "Address", style: TextStyle( @@ -180,8 +180,8 @@ class _CheckoutFormState extends State { const SizedBox( height: 20, ), - Row( - children: const [ + const Row( + children: [ Text( "Shipping Methods", style: TextStyle( diff --git a/lib/components/checkout_items.dart b/lib/components/checkout_items.dart index 900ad04..c412def 100644 --- a/lib/components/checkout_items.dart +++ b/lib/components/checkout_items.dart @@ -1,9 +1,9 @@ import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/data/cart.dart'; -import 'package:nekoya_flutter/components/cart_box.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/data/cart.dart'; +import 'package:nekoya_app/components/cart_box.dart'; class CheckoutItems extends StatefulWidget { const CheckoutItems({Key? key}) : super(key: key); @@ -13,7 +13,6 @@ class CheckoutItems extends StatefulWidget { } class _CheckoutItemsState extends State { - @override Widget build(BuildContext context) { Future getTotal() async { @@ -69,7 +68,8 @@ class _CheckoutItemsState extends State { if (productData != null) { return CartBox( controller: false, - imageUrl: "https://nekoya.moe.team/img/${productData[0]['IMAGE']}", + imageUrl: + "https://nekoya.moe.team/img/${productData[0]['IMAGE']}", title: productData[0]['TITLE'], quantity: data[index]["quantity"], plus: () {}, @@ -123,9 +123,9 @@ class _CheckoutItemsState extends State { ); } - return Row( + return const Row( mainAxisAlignment: MainAxisAlignment.end, - children: const [ + children: [ Text( "Total : -", style: TextStyle( diff --git a/lib/components/color_dot.dart b/lib/components/color_dot.dart index b28350d..e594360 100644 --- a/lib/components/color_dot.dart +++ b/lib/components/color_dot.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/utils/utils.dart'; class ColorDot extends StatelessWidget { const ColorDot({ diff --git a/lib/components/forgot_pass_body.dart b/lib/components/forgot_pass_body.dart index 5bfdef1..5c527f0 100644 --- a/lib/components/forgot_pass_body.dart +++ b/lib/components/forgot_pass_body.dart @@ -1,7 +1,7 @@ import 'package:lottie/lottie.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; +import 'package:nekoya_app/api/api.dart'; class ForgotPassBody extends StatefulWidget { const ForgotPassBody({Key? key}) : super(key: key); @@ -45,8 +45,8 @@ class _ForgotPassBodyState extends State { ), Container( padding: const EdgeInsets.only(top: 25, bottom: 20), - child: Row( - children: const [ + child: const Row( + children: [ Icon( Icons.mail_sharp, color: Colors.white, @@ -75,7 +75,9 @@ class _ForgotPassBodyState extends State { ), ), ), - const SizedBox(height: 10,), + const SizedBox( + height: 10, + ), ElevatedButton( style: ButtonStyle( padding: MaterialStateProperty.all(const EdgeInsets.all(15.0)), @@ -94,32 +96,37 @@ class _ForgotPassBodyState extends State { forgotForm(context).then((res) { if (res['statusCode'] == 200) { showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Forgot Password', style: TextStyle(color: Colors.white),), - backgroundColor: const Color(0xff212226), - content: SingleChildScrollView( - child: ListBody( - children: const [ - Text('Please check your email to reset your password', style: TextStyle( - color: Colors.white - )), - ], + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: const Text( + 'Forgot Password', + style: TextStyle(color: Colors.white), ), - ), - actions: [ - TextButton( - child: const Text('Close', style: TextStyle(color: Colors.white),), - onPressed: () { - Navigator.of(context).pop(); - }, + backgroundColor: const Color(0xff212226), + content: const SingleChildScrollView( + child: ListBody( + children: [ + Text( + 'Please check your email to reset your password', + style: TextStyle(color: Colors.white)), + ], + ), ), - ], - ); - } - ); + actions: [ + TextButton( + child: const Text( + 'Close', + style: TextStyle(color: Colors.white), + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }); } else if (res['statusCode'] == 205) { showEmailWarn(context); } else { diff --git a/lib/components/login_form.dart b/lib/components/login_form.dart index fdcc21a..4cf6db9 100644 --- a/lib/components/login_form.dart +++ b/lib/components/login_form.dart @@ -1,11 +1,11 @@ import 'package:lottie/lottie.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/menu.dart'; -import 'package:nekoya_flutter/data/auth.dart'; -import 'package:nekoya_flutter/screens/otp.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/menu.dart'; +import 'package:nekoya_app/data/auth.dart'; +import 'package:nekoya_app/screens/otp.dart'; +import 'package:nekoya_app/utils/utils.dart'; class LoginForm extends StatefulWidget { const LoginForm({Key? key}) : super(key: key); diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 9f6f1a6..5182f08 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -2,12 +2,12 @@ import 'dart:math' as math; import 'package:universal_html/html.dart' as html; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/data/auth.dart'; -import 'package:nekoya_flutter/screens/products.dart'; -import 'package:nekoya_flutter/screens/cart.dart'; -import 'package:nekoya_flutter/screens/sessions.dart'; -import 'package:nekoya_flutter/screens/transactions.dart'; -import 'package:nekoya_flutter/screens/home.dart'; +import 'package:nekoya_app/data/auth.dart'; +import 'package:nekoya_app/screens/products.dart'; +import 'package:nekoya_app/screens/cart.dart'; +import 'package:nekoya_app/screens/sessions.dart'; +import 'package:nekoya_app/screens/transactions.dart'; +import 'package:nekoya_app/screens/home.dart'; class Menu extends StatefulWidget { const Menu({Key? key, required this.initialScreen}) : super(key: key); diff --git a/lib/components/new_arrival_products.dart b/lib/components/new_arrival_products.dart index c673fc3..8db26b4 100644 --- a/lib/components/new_arrival_products.dart +++ b/lib/components/new_arrival_products.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/product_detail.dart'; -import 'package:nekoya_flutter/components/product_card.dart'; -import 'package:nekoya_flutter/components/section_title.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/product_detail.dart'; +import 'package:nekoya_app/components/product_card.dart'; +import 'package:nekoya_app/components/section_title.dart'; +import 'package:nekoya_app/utils/utils.dart'; class NewArrivalProducts extends StatelessWidget { const NewArrivalProducts({ @@ -23,61 +23,63 @@ class NewArrivalProducts extends StatelessWidget { ), ), FutureBuilder( - future: getProducts(), - builder: (context, snapshot) { - if (snapshot.hasData) { - var sourceData = snapshot.data; - sourceData.shuffle(); - var data = sourceData.take(6).toList(); - return SingleChildScrollView( - physics: const BouncingScrollPhysics( - parent: AlwaysScrollableScrollPhysics()), - scrollDirection: Axis.horizontal, - child: Row( - children: List.generate( - data.length, - (index) => Padding( - padding: const EdgeInsets.only(right: defaultPadding), - child: ProductCard( - title: data[index]['TITLE'], - imageUrl: "https://nekoya.moe.team/img/${data[index]['IMAGE']}", - bgColor: const Color(0xFFFEFBF9), - press: () { - showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - context: context, - builder: (context) => productDetail(context, data[index]['ID']), - ); - }, + future: getProducts(), + builder: (context, snapshot) { + if (snapshot.hasData) { + var sourceData = snapshot.data; + sourceData.shuffle(); + var data = sourceData.take(6).toList(); + return SingleChildScrollView( + physics: const BouncingScrollPhysics( + parent: AlwaysScrollableScrollPhysics()), + scrollDirection: Axis.horizontal, + child: Row( + children: List.generate( + data.length, + (index) => Padding( + padding: const EdgeInsets.only(right: defaultPadding), + child: ProductCard( + title: data[index]['TITLE'], + imageUrl: + "https://nekoya.moe.team/img/${data[index]['IMAGE']}", + bgColor: const Color(0xFFFEFBF9), + press: () { + showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + context: context, + builder: (context) => + productDetail(context, data[index]['ID']), + ); + }, + ), ), ), ), - ), - ); - } else { - return SingleChildScrollView( - physics: const BouncingScrollPhysics( - parent: AlwaysScrollableScrollPhysics()), - scrollDirection: Axis.horizontal, - child: Row( - children: List.generate( - 6, - (index) => Padding( - padding: const EdgeInsets.only(right: defaultPadding), - child: ProductCard( - title: 'Loading...', - imageUrl: "https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp", - bgColor: const Color(0xFFFEFBF9), - press: () {}, + ); + } else { + return SingleChildScrollView( + physics: const BouncingScrollPhysics( + parent: AlwaysScrollableScrollPhysics()), + scrollDirection: Axis.horizontal, + child: Row( + children: List.generate( + 6, + (index) => Padding( + padding: const EdgeInsets.only(right: defaultPadding), + child: ProductCard( + title: 'Loading...', + imageUrl: + "https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp", + bgColor: const Color(0xFFFEFBF9), + press: () {}, + ), ), ), ), - ), - ); - } - } - ) + ); + } + }) ], ); } diff --git a/lib/components/newsletter.dart b/lib/components/newsletter.dart index 1acbb0e..59fe8f8 100644 --- a/lib/components/newsletter.dart +++ b/lib/components/newsletter.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/utils/utils.dart'; const OutlineInputBorder outlineInputBorder = OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(12)), @@ -62,7 +62,8 @@ class _NewsletterState extends State { padding: const EdgeInsets.all(14), child: SvgPicture.asset( "assets/icons/email.svg", - color: Colors.white, + colorFilter: const ColorFilter.mode( + Colors.white, BlendMode.srcIn), width: 21.5, height: 21.5, ), @@ -76,7 +77,7 @@ class _NewsletterState extends State { height: 48, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: const Color(0xff8B0000), + backgroundColor: const Color(0xff8B0000), shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(12)), @@ -87,34 +88,46 @@ class _NewsletterState extends State { subscribe(emailQuery).then((status) { if (status == 200) { emailController.clear(); - FocusScope.of(context).requestFocus(FocusNode()); + FocusScope.of(context) + .requestFocus(FocusNode()); return showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Thank You', style: TextStyle(color: Colors.white),), - backgroundColor: const Color(0xff212226), - content: SingleChildScrollView( - child: ListBody( - children: const [ - Text('You have successfully subscribed to the newsletter.', style: TextStyle( - color: Colors.white - )), - ], + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: const Text( + 'Thank You', + style: TextStyle( + color: Colors.white), ), - ), - actions: [ - TextButton( - child: const Text('Close', style: TextStyle(color: Colors.white),), - onPressed: () { - Navigator.of(context).pop(); - }, + backgroundColor: + const Color(0xff212226), + content: + const SingleChildScrollView( + child: ListBody( + children: [ + Text( + 'You have successfully subscribed to the newsletter.', + style: TextStyle( + color: + Colors.white)), + ], + ), ), - ], - ); - } - ); + actions: [ + TextButton( + child: const Text( + 'Close', + style: TextStyle( + color: Colors.white), + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }); } }); } diff --git a/lib/components/otp_body.dart b/lib/components/otp_body.dart index 3b41f7a..dd465eb 100644 --- a/lib/components/otp_body.dart +++ b/lib/components/otp_body.dart @@ -2,9 +2,9 @@ import 'package:lottie/lottie.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/menu.dart'; -import 'package:nekoya_flutter/data/auth.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/menu.dart'; +import 'package:nekoya_app/data/auth.dart'; class OtpBody extends StatefulWidget { const OtpBody({Key? key, required this.otpToken}) : super(key: key); @@ -24,12 +24,18 @@ class _OtpBodyState extends State { TextEditingController otpCode6 = TextEditingController(); Future submitForm(BuildContext context) async { - if (otpCode1.text.isEmpty || otpCode2.text.isEmpty || otpCode3.text.isEmpty || otpCode4.text.isEmpty || otpCode5.text.isEmpty || otpCode6.text.isEmpty) { + if (otpCode1.text.isEmpty || + otpCode2.text.isEmpty || + otpCode3.text.isEmpty || + otpCode4.text.isEmpty || + otpCode5.text.isEmpty || + otpCode6.text.isEmpty) { return 999; } else { Map data = { "token": widget.otpToken, - "code": "${otpCode1.text}${otpCode2.text}${otpCode3.text}${otpCode4.text}${otpCode5.text}${otpCode6.text}" + "code": + "${otpCode1.text}${otpCode2.text}${otpCode3.text}${otpCode4.text}${otpCode5.text}${otpCode6.text}" }; var response = await otpPost(data); @@ -255,7 +261,9 @@ class _OtpBodyState extends State { ], ), )), - const SizedBox(height: 30,), + const SizedBox( + height: 30, + ), ElevatedButton( style: ButtonStyle( padding: MaterialStateProperty.all(const EdgeInsets.all(15.0)), @@ -272,9 +280,10 @@ class _OtpBodyState extends State { if (res['statusCode'] == 200) { addSession(res['data']['id'], res['data']['session_token']); Navigator.pop(context); - Navigator.pushReplacement(context, MaterialPageRoute( - builder: (context) => const Menu(initialScreen: 2) - )); + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => const Menu(initialScreen: 2))); Navigator.pop(context); } }); diff --git a/lib/components/payment_body.dart b/lib/components/payment_body.dart index 131e5e0..ec23b93 100644 --- a/lib/components/payment_body.dart +++ b/lib/components/payment_body.dart @@ -1,8 +1,8 @@ import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/data/cart.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/data/cart.dart'; class PaymentBody extends StatefulWidget { const PaymentBody({Key? key}) : super(key: key); @@ -181,9 +181,9 @@ class _PaymentBodyState extends State { ); } - return Row( + return const Row( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Text( "Count total price on process!", style: TextStyle( diff --git a/lib/components/popular_products.dart b/lib/components/popular_products.dart index 6300791..77fcf0d 100644 --- a/lib/components/popular_products.dart +++ b/lib/components/popular_products.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/product_card.dart'; -import 'package:nekoya_flutter/components/product_detail.dart'; -import 'package:nekoya_flutter/components/section_title.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/product_card.dart'; +import 'package:nekoya_app/components/product_detail.dart'; +import 'package:nekoya_app/components/section_title.dart'; +import 'package:nekoya_app/utils/utils.dart'; class PopularProducts extends StatelessWidget { const PopularProducts({ diff --git a/lib/components/product_card.dart b/lib/components/product_card.dart index 72dec72..0e2faf8 100644 --- a/lib/components/product_card.dart +++ b/lib/components/product_card.dart @@ -1,7 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/utils/utils.dart'; class ProductCard extends StatelessWidget { const ProductCard({ @@ -32,17 +32,16 @@ class ProductCard extends StatelessWidget { width: double.infinity, decoration: const BoxDecoration( color: Color(0xff212226), - borderRadius: BorderRadius.all( - Radius.circular(defaultBorderRadius)), + borderRadius: + BorderRadius.all(Radius.circular(defaultBorderRadius)), ), child: CachedNetworkImage( imageUrl: imageUrl, - placeholder: (context, url) => - const Center( - child: CircularProgressIndicator( - color: Color(0xff8B0000), + placeholder: (context, url) => const Center( + child: CircularProgressIndicator( + color: Color(0xff8B0000), + ), ), - ), errorWidget: (context, url, error) => Image.asset('assets/images/image_error.webp'), fadeOutDuration: const Duration(milliseconds: 5), diff --git a/lib/components/product_detail.dart b/lib/components/product_detail.dart index d827b7f..270d485 100644 --- a/lib/components/product_detail.dart +++ b/lib/components/product_detail.dart @@ -2,9 +2,9 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/data/cart.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/data/cart.dart'; +import 'package:nekoya_app/utils/utils.dart'; Widget makeDismissible({required context, required Widget child}) => GestureDetector( diff --git a/lib/components/register_error.dart b/lib/components/register_error.dart index d6fc75f..c37810e 100644 --- a/lib/components/register_error.dart +++ b/lib/components/register_error.dart @@ -58,9 +58,9 @@ class RegisterErrorState extends State { const SizedBox( height: 70, ), - Row( + const Row( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Flexible( child: Text( "An error has occured Make sure to check if your email has been registered before.", diff --git a/lib/components/register_form.dart b/lib/components/register_form.dart index 49a33c6..6174d50 100644 --- a/lib/components/register_form.dart +++ b/lib/components/register_form.dart @@ -2,9 +2,9 @@ import 'package:lottie/lottie.dart'; import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/register_error.dart'; -import 'package:nekoya_flutter/components/register_verify.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/register_error.dart'; +import 'package:nekoya_app/components/register_verify.dart'; class RegisterForm extends StatefulWidget { const RegisterForm({Key? key}) : super(key: key); @@ -144,7 +144,7 @@ class RegisterFormState extends State { children: [ TextButton( style: TextButton.styleFrom( - primary: Colors.transparent, + foregroundColor: Colors.transparent, ), child: const Text( "Already have an account?? \nClick here to Sign In !!", diff --git a/lib/components/register_verify.dart b/lib/components/register_verify.dart index a888701..198f973 100644 --- a/lib/components/register_verify.dart +++ b/lib/components/register_verify.dart @@ -58,9 +58,9 @@ class RegisterVerifyState extends State { const SizedBox( height: 50, ), - Row( + const Row( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Flexible( child: Text( "Before proceeding, please check your email for a verification link to verify your email address.", diff --git a/lib/components/search_form.dart b/lib/components/search_form.dart index 86872eb..45da24f 100644 --- a/lib/components/search_form.dart +++ b/lib/components/search_form.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:nekoya_flutter/components/search_page.dart'; +import 'package:nekoya_app/components/search_page.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/utils/utils.dart'; const OutlineInputBorder outlineInputBorder = OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(12)), @@ -37,7 +37,8 @@ class _SearchFormState extends State { prefixIcon: Padding( padding: const EdgeInsets.all(14), child: SvgPicture.asset("assets/icons/Search.svg", - color: Colors.white), + colorFilter: + const ColorFilter.mode(Colors.white, BlendMode.srcIn)), ), suffixIcon: Padding( padding: const EdgeInsets.symmetric( @@ -47,7 +48,7 @@ class _SearchFormState extends State { height: 48, child: ElevatedButton( style: ElevatedButton.styleFrom( - primary: const Color(0xff8B0000), + backgroundColor: const Color(0xff8B0000), shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(12)), ), diff --git a/lib/components/search_page.dart b/lib/components/search_page.dart index 8a453aa..61c97ea 100644 --- a/lib/components/search_page.dart +++ b/lib/components/search_page.dart @@ -1,9 +1,9 @@ import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/product_detail.dart'; -import 'package:nekoya_flutter/components/search_item.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/product_detail.dart'; +import 'package:nekoya_app/components/search_item.dart'; class SearchPage extends StatefulWidget { const SearchPage({Key? key, required this.query}) : super(key: key); @@ -25,39 +25,47 @@ class _SearchPageState extends State { backgroundColor: const Color(0xff212226), ), body: FutureBuilder( - future: getProducts(), - builder: (context, snapshot) { - if (snapshot.hasData) { - var data = snapshot.data; - var filteredData = data.where((x) => x['TITLE'].toLowerCase().contains(widget.query.toLowerCase()) ? true : false).toList(); - return ListView.separated( - separatorBuilder: (BuildContext context, int index) => const Divider(), - itemCount: filteredData.length, - itemBuilder: (context, index) { - return SearchItem( - title: filteredData[index]['TITLE'], - description: "Price : Rp ${NumberFormat('#,##0.00', 'ID').format(filteredData[index]['PRICE'])}", - imageUrl: "https://nekoya.moe.team/img/${filteredData[index]['IMAGE']}", - callback: () { - showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - context: context, - builder: (context) => productDetail(context, filteredData[index]['ID']), + future: getProducts(), + builder: (context, snapshot) { + if (snapshot.hasData) { + var data = snapshot.data; + var filteredData = data + .where((x) => x['TITLE'] + .toLowerCase() + .contains(widget.query.toLowerCase()) + ? true + : false) + .toList(); + return ListView.separated( + separatorBuilder: (BuildContext context, int index) => + const Divider(), + itemCount: filteredData.length, + itemBuilder: (context, index) { + return SearchItem( + title: filteredData[index]['TITLE'], + description: + "Price : Rp ${NumberFormat('#,##0.00', 'ID').format(filteredData[index]['PRICE'])}", + imageUrl: + "https://nekoya.moe.team/img/${filteredData[index]['IMAGE']}", + callback: () { + showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + context: context, + builder: (context) => + productDetail(context, filteredData[index]['ID']), + ); + }, ); - }, - ); - } + }); + } + + return const Center( + child: CircularProgressIndicator( + color: Color(0xff8B0000), + ), ); - } - - return const Center( - child: CircularProgressIndicator( - color: Color(0xff8B0000), - ), - ); - } - ), + }), ); } -} \ No newline at end of file +} diff --git a/lib/components/section_title.dart b/lib/components/section_title.dart index 8e39518..d464127 100644 --- a/lib/components/section_title.dart +++ b/lib/components/section_title.dart @@ -16,7 +16,7 @@ class SectionTitle extends StatelessWidget { children: [ Text( title, - style: Theme.of(context).textTheme.subtitle1!.copyWith( + style: Theme.of(context).textTheme.titleMedium!.copyWith( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 20.0, diff --git a/lib/components/transaction_box.dart b/lib/components/transaction_box.dart index d9fe509..579ca40 100644 --- a/lib/components/transaction_box.dart +++ b/lib/components/transaction_box.dart @@ -2,26 +2,26 @@ import 'dart:convert'; import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/transaction_product_box.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/transaction_product_box.dart'; class TransactionBox extends StatefulWidget { - const TransactionBox({ - Key? key, - required this.orderId, - required this.status, - required this.firstName, - required this.lastName, - required this.phoneNumber, - required this.streetAddress1, - required this.district, - required this.subDistrict, - required this.province, - required this.region, - required this.postalCode, - required this.logistic, - required this.data - }) : super(key: key); + const TransactionBox( + {Key? key, + required this.orderId, + required this.status, + required this.firstName, + required this.lastName, + required this.phoneNumber, + required this.streetAddress1, + required this.district, + required this.subDistrict, + required this.province, + required this.region, + required this.postalCode, + required this.logistic, + required this.data}) + : super(key: key); final int orderId; final String status; @@ -54,7 +54,7 @@ class _TransactionBoxState extends State { totalPrice += product[0]['PRICE'] * x['quantity']; }); - return Future.delayed(const Duration(seconds: 2), (){ + return Future.delayed(const Duration(seconds: 2), () { return totalPrice; }); } @@ -66,8 +66,14 @@ class _TransactionBoxState extends State { title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('#${widget.orderId}', style: const TextStyle(color: Colors.white),), - Text(widget.status, style: const TextStyle(color: Colors.white),) + Text( + '#${widget.orderId}', + style: const TextStyle(color: Colors.white), + ), + Text( + widget.status, + style: const TextStyle(color: Colors.white), + ) ], ), children: [ @@ -78,15 +84,31 @@ class _TransactionBoxState extends State { Flexible( flex: 2, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text('Sender Details', style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w600),), - const SizedBox(height: 5,), - Text("${widget.firstName} ${widget.lastName}", style: const TextStyle(color: Colors.white),), - Text(widget.phoneNumber, style: const TextStyle(color: Colors.white),), - Text("${widget.streetAddress1}, ${widget.district}, ${widget.subDistrict}, ${widget.province}, ${widget.region}, ${widget.postalCode}", style: const TextStyle(color: Colors.white),), - ] - ), + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Sender Details', + style: TextStyle( + color: Colors.white, + fontSize: 15, + fontWeight: FontWeight.w600), + ), + const SizedBox( + height: 5, + ), + Text( + "${widget.firstName} ${widget.lastName}", + style: const TextStyle(color: Colors.white), + ), + Text( + widget.phoneNumber, + style: const TextStyle(color: Colors.white), + ), + Text( + "${widget.streetAddress1}, ${widget.district}, ${widget.subDistrict}, ${widget.province}, ${widget.region}, ${widget.postalCode}", + style: const TextStyle(color: Colors.white), + ), + ]), ), Flexible( flex: 1, @@ -96,9 +118,20 @@ class _TransactionBoxState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - const Text('Logistic', style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w600),), - const SizedBox(height: 5,), - Text(widget.logistic, style: const TextStyle(color: Colors.white),), + const Text( + 'Logistic', + style: TextStyle( + color: Colors.white, + fontSize: 14, + fontWeight: FontWeight.w600), + ), + const SizedBox( + height: 5, + ), + Text( + widget.logistic, + style: const TextStyle(color: Colors.white), + ), ], ), ), @@ -106,7 +139,6 @@ class _TransactionBoxState extends State { ], ), ), - Container( margin: const EdgeInsets.all(15.0), child: Card( @@ -117,77 +149,73 @@ class _TransactionBoxState extends State { child: Column( children: [ ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemCount: orderData.length, - itemBuilder: (context, index) { - return FutureBuilder( - future: getProduct(orderData[index]['product_id']), - builder: (context, snapshot) { - if (snapshot.hasData) { - var productData = snapshot.data; - return TransactionProductBox( - imageUrl: 'https://nekoya.moe.team/img/${productData[0]['IMAGE']}', - title: productData[0]['TITLE'], - quantity: orderData[index]["quantity"], - ); - } - - return const TransactionProductBox( - imageUrl: 'https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp', - title: 'Loading...', - quantity: 0, - ); - } - ); - } - ), + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: orderData.length, + itemBuilder: (context, index) { + return FutureBuilder( + future: getProduct(orderData[index]['product_id']), + builder: (context, snapshot) { + if (snapshot.hasData) { + var productData = snapshot.data; + return TransactionProductBox( + imageUrl: + 'https://nekoya.moe.team/img/${productData[0]['IMAGE']}', + title: productData[0]['TITLE'], + quantity: orderData[index]["quantity"], + ); + } + return const TransactionProductBox( + imageUrl: + 'https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp', + title: 'Loading...', + quantity: 0, + ); + }); + }), Container( margin: const EdgeInsets.only(left: 15.0, right: 15.0), child: const Divider( color: Colors.white, ), ), - Container( - margin: const EdgeInsets.only(top: 15.0, right: 15.0, bottom: 20.0), + margin: const EdgeInsets.only( + top: 15.0, right: 15.0, bottom: 20.0), child: FutureBuilder( - future: getTotal(), - builder: (context, snapshot) { - if (snapshot.hasData) { - var price = snapshot.data; - return Row( + future: getTotal(), + builder: (context, snapshot) { + if (snapshot.hasData) { + var price = snapshot.data; + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + "Total : Rp ${NumberFormat('#,##0.00', 'ID').format(price)}", + style: const TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600), + ) + ], + ); + } + + return const Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - "Total : Rp ${NumberFormat('#,##0.00', 'ID').format(price)}", - style: const TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.w600 - ), + "Total : -", + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.w600), ) ], ); - } - - return Row( - mainAxisAlignment: MainAxisAlignment.end, - children: const [ - Text( - "Total : -", - style: TextStyle( - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.w600 - ), - ) - ], - ); - } - ), + }), ), ], ), @@ -196,4 +224,4 @@ class _TransactionBoxState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/data/auth.dart b/lib/data/auth.dart index 0096dca..1afce20 100644 --- a/lib/data/auth.dart +++ b/lib/data/auth.dart @@ -1,13 +1,10 @@ import 'dart:convert'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:nekoya_flutter/api/api.dart'; +import 'package:nekoya_app/api/api.dart'; String getEncodedSession(userId, sessionToken) { - var sessionData = { - "user_id": userId, - "session_token": sessionToken - }; + var sessionData = {"user_id": userId, "session_token": sessionToken}; var sessionRaw = jsonEncode(sessionData).toString(); var sessionEncoded = base64.encode(utf8.encode(sessionRaw)); return sessionEncoded; @@ -52,4 +49,4 @@ Future removeSession() async { final prefs = await SharedPreferences.getInstance(); await prefs.remove('session'); -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index c048812..2720c55 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,14 @@ -import 'package:nekoya_flutter/screens/forgotpassword.dart'; +import 'package:nekoya_app/screens/forgotpassword.dart'; import 'package:page_transition/page_transition.dart'; import 'package:animated_splash_screen/animated_splash_screen.dart'; import 'package:flutter/services.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/screens/login.dart'; -import 'package:nekoya_flutter/screens/register.dart'; -import 'package:nekoya_flutter/screens/payment.dart'; -import 'package:nekoya_flutter/components/menu.dart'; -import 'package:nekoya_flutter/utils/navigation_auth.dart'; +import 'package:nekoya_app/screens/login.dart'; +import 'package:nekoya_app/screens/register.dart'; +import 'package:nekoya_app/screens/payment.dart'; +import 'package:nekoya_app/components/menu.dart'; +import 'package:nekoya_app/utils/navigation_auth.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); diff --git a/lib/screens/about_us.dart b/lib/screens/about_us.dart index d3ecc55..e18cc1d 100644 --- a/lib/screens/about_us.dart +++ b/lib/screens/about_us.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/about_us_body.dart'; +import 'package:nekoya_app/components/about_us_body.dart'; class AboutUs extends StatefulWidget { const AboutUs({Key? key}) : super(key: key); diff --git a/lib/screens/cart.dart b/lib/screens/cart.dart index 20d0a5a..e6dd7a6 100644 --- a/lib/screens/cart.dart +++ b/lib/screens/cart.dart @@ -1,12 +1,12 @@ import 'package:intl/intl.dart'; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/cart_box.dart'; -import 'package:nekoya_flutter/components/cart_button.dart'; -import 'package:nekoya_flutter/components/menu.dart'; -import 'package:nekoya_flutter/data/cart.dart'; -import 'package:nekoya_flutter/screens/checkout.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/cart_box.dart'; +import 'package:nekoya_app/components/cart_button.dart'; +import 'package:nekoya_app/components/menu.dart'; +import 'package:nekoya_app/data/cart.dart'; +import 'package:nekoya_app/screens/checkout.dart'; class Cart extends StatefulWidget { const Cart({Key? key}) : super(key: key); @@ -20,7 +20,6 @@ class _CartState extends State { @override Widget build(BuildContext context) { - Future getTotal() async { dynamic totalPrice = 0; var orderData = await viewCart(); @@ -47,119 +46,118 @@ class _CartState extends State { body: Container( margin: const EdgeInsets.only(bottom: 80.0), child: FutureBuilder( - future: _viewCart, - builder: (context, snapshot) { - if (snapshot.hasData) { - var data = snapshot.data; - if (data.isNotEmpty) { - return ListView.builder( - itemCount: data!.length, - itemBuilder: (context, index) { - return FutureBuilder( - future: getProduct(data[index]["product_id"]), - builder: (context, snapshotx) { - if (snapshotx.hasData) { - var productData = snapshotx.data; - if (productData != null) { + future: _viewCart, + builder: (context, snapshot) { + if (snapshot.hasData) { + var data = snapshot.data; + if (data.isNotEmpty) { + return ListView.builder( + itemCount: data!.length, + itemBuilder: (context, index) { + return FutureBuilder( + future: getProduct(data[index]["product_id"]), + builder: (context, snapshotx) { + if (snapshotx.hasData) { + var productData = snapshotx.data; + if (productData != null) { + return CartBox( + controller: true, + imageUrl: + "https://nekoya.moe.team/img/${productData[0]['IMAGE']}", + title: productData[0]['TITLE'], + quantity: data[index]["quantity"], + plus: () { + addToCart(data[index]["product_id"]); + setState(() { + _viewCart = viewCart(); + getTotal_ = getTotal(); + }); + }, + minus: () { + removeFromCart( + data[index]["product_id"], false); + setState(() { + _viewCart = viewCart(); + getTotal_ = getTotal(); + }); + }, + remove: () { + removeFromCart( + data[index]["product_id"], true); + setState(() { + _viewCart = viewCart(); + getTotal_ = getTotal(); + }); + }); + } + } + return CartBox( controller: true, - imageUrl: "https://nekoya.moe.team/img/${productData[0]['IMAGE']}", - title: productData[0]['TITLE'], - quantity: data[index]["quantity"], - plus: () { - addToCart(data[index]["product_id"]); - setState(() { - _viewCart = viewCart(); - getTotal_ = getTotal(); - }); - }, - minus: () { - removeFromCart(data[index]["product_id"], false); - setState(() { - _viewCart = viewCart(); - getTotal_ = getTotal(); - }); - }, - remove: () { - removeFromCart(data[index]["product_id"], true); - setState(() { - _viewCart = viewCart(); - getTotal_ = getTotal(); - }); - } + imageUrl: + 'https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp', + title: 'Loading...', + quantity: 0, + plus: () {}, + minus: () {}, + remove: () {}, ); - } - } - - return CartBox( - controller: true, - imageUrl: 'https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp', - title: 'Loading...', - quantity: 0, - plus: () {}, - minus: () {}, - remove: () {}, - ); - } - ); - }, - ); - } else { - return Padding( - padding: const EdgeInsets.only(bottom: 200.0), - child: Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage('assets/images/image_empty.webp') - ) + }); + }, + ); + } else { + return Padding( + padding: const EdgeInsets.only(bottom: 200.0), + child: Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/images/image_empty.webp'))), ), - ), - ); + ); + } } - } - return const Center( - child: CircularProgressIndicator( - color: Color(0xff8B0000), - ), - ); - } - ), + return const Center( + child: CircularProgressIndicator( + color: Color(0xff8B0000), + ), + ); + }), ), floatingActionButton: FutureBuilder( - future: getTotal_, - builder: (context, snapshot) { - if (snapshot.hasData) { - var price = snapshot.data; - if (price != 0) { + future: getTotal_, + builder: (context, snapshot) { + if (snapshot.hasData) { + var price = snapshot.data; + if (price != 0) { + return CartButton( + icon: const Icon(Icons.shopping_cart_checkout), + text1: "Rp ${NumberFormat('#,##0.00', 'ID').format(price)}", + text2: "Checkout", + refer: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => const Checkout())); + }, + ); + } + return CartButton( - icon: const Icon(Icons.shopping_cart_checkout), - text1: "Rp ${NumberFormat('#,##0.00', 'ID').format(price)}", - text2: "Checkout", + icon: const Icon(Icons.shopping_cart_outlined), + text1: "Cart is Empty", + text2: "Shop Now", refer: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => const Checkout()) - ); + Navigator.of(context).pushReplacement(MaterialPageRoute( + builder: (context) => const Menu(initialScreen: 2))); }, ); } - return CartButton( - icon: const Icon(Icons.shopping_cart_outlined), - text1: "Cart is Empty", - text2: "Shop Now", - refer: () { - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => const Menu(initialScreen: 2)) - ); - }, + return const SizedBox( + width: 1.0, ); - } - - return const SizedBox(width: 1.0,); - } - ), + }), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); } -} \ No newline at end of file +} diff --git a/lib/screens/checkout.dart b/lib/screens/checkout.dart index aa3a4da..fffb35e 100644 --- a/lib/screens/checkout.dart +++ b/lib/screens/checkout.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/checkout_form.dart'; -import 'package:nekoya_flutter/components/checkout_items.dart'; +import 'package:nekoya_app/components/checkout_form.dart'; +import 'package:nekoya_app/components/checkout_items.dart'; class Checkout extends StatefulWidget { const Checkout({Key? key}) : super(key: key); @@ -20,10 +20,10 @@ class _CheckoutState extends State { centerTitle: true, backgroundColor: const Color(0xff212226), ), - body: SafeArea( + body: const SafeArea( child: SingleChildScrollView( child: Column( - children: const [ + children: [ CheckoutItems(), CheckoutForm(), ], diff --git a/lib/screens/faq.dart b/lib/screens/faq.dart index dee9940..40c9174 100644 --- a/lib/screens/faq.dart +++ b/lib/screens/faq.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/faq_body.dart'; +import 'package:nekoya_app/components/faq_body.dart'; class FAQ extends StatefulWidget { const FAQ({Key? key}) : super(key: key); @@ -13,13 +13,12 @@ class _FAQState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color(0xff1b1c1e), - appBar: AppBar( - title: const Text('FAQ'), - centerTitle: true, - backgroundColor: const Color(0xff212226), - ), - body: const FAQBody() - ); + backgroundColor: const Color(0xff1b1c1e), + appBar: AppBar( + title: const Text('FAQ'), + centerTitle: true, + backgroundColor: const Color(0xff212226), + ), + body: const FAQBody()); } -} \ No newline at end of file +} diff --git a/lib/screens/forgotpassword.dart b/lib/screens/forgotpassword.dart index fc90518c..97b5732 100644 --- a/lib/screens/forgotpassword.dart +++ b/lib/screens/forgotpassword.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/forgot_pass_body.dart'; +import 'package:nekoya_app/components/forgot_pass_body.dart'; class ForgotPassword extends StatefulWidget { const ForgotPassword({Key? key}) : super(key: key); diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 57366df..508ddc9 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/bannerimage.dart'; -import 'package:nekoya_flutter/components/carousel.dart'; -import 'package:nekoya_flutter/components/new_arrival_products.dart'; -import 'package:nekoya_flutter/components/newsletter.dart'; -import 'package:nekoya_flutter/components/popular_products.dart'; -import 'package:nekoya_flutter/components/search_form.dart'; -import 'package:nekoya_flutter/screens/about_us.dart'; -import 'package:nekoya_flutter/screens/faq.dart'; -import 'package:nekoya_flutter/utils/utils.dart'; +import 'package:nekoya_app/components/bannerimage.dart'; +import 'package:nekoya_app/components/carousel.dart'; +import 'package:nekoya_app/components/new_arrival_products.dart'; +import 'package:nekoya_app/components/newsletter.dart'; +import 'package:nekoya_app/components/popular_products.dart'; +import 'package:nekoya_app/components/search_form.dart'; +import 'package:nekoya_app/screens/about_us.dart'; +import 'package:nekoya_app/screens/faq.dart'; +import 'package:nekoya_app/utils/utils.dart'; class Home extends StatelessWidget { const Home({Key? key}) : super(key: key); @@ -51,7 +51,7 @@ class Home extends StatelessWidget { "Explore", style: Theme.of(context) .textTheme - .headline4! + .headlineMedium! .copyWith(fontWeight: FontWeight.w500, color: Colors.white), ), const Text( diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 04e7fcb..3195626 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/login_form.dart'; +import 'package:nekoya_app/components/login_form.dart'; class Login extends StatefulWidget { const Login({Key? key}) : super(key: key); diff --git a/lib/screens/otp.dart b/lib/screens/otp.dart index 4f8a3bf..b4c6a7d 100644 --- a/lib/screens/otp.dart +++ b/lib/screens/otp.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/otp_body.dart'; +import 'package:nekoya_app/components/otp_body.dart'; class Otp extends StatefulWidget { const Otp({Key? key, required this.otpToken}) : super(key: key); @@ -21,7 +21,9 @@ class _OtpState extends State { centerTitle: true, backgroundColor: const Color(0xff212226), ), - body: OtpBody(otpToken: widget.otpToken,), + body: OtpBody( + otpToken: widget.otpToken, + ), ); } } diff --git a/lib/screens/payment.dart b/lib/screens/payment.dart index abf0a20..95dfabb 100644 --- a/lib/screens/payment.dart +++ b/lib/screens/payment.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/payment_body.dart'; +import 'package:nekoya_app/components/payment_body.dart'; class Payment extends StatefulWidget { const Payment({Key? key}) : super(key: key); diff --git a/lib/screens/products.dart b/lib/screens/products.dart index d3ebe34..0a39280 100644 --- a/lib/screens/products.dart +++ b/lib/screens/products.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/product_box.dart'; -import 'package:nekoya_flutter/components/product_detail.dart'; -import 'package:nekoya_flutter/utils/utils.dart' +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/product_box.dart'; +import 'package:nekoya_app/components/product_detail.dart'; +import 'package:nekoya_app/utils/utils.dart' show kMobileBreakpoint, kTabletBreakpoint, kDesktopBreakPoint; class Products extends StatefulWidget { diff --git a/lib/screens/register.dart b/lib/screens/register.dart index ee8b65b..d3f7a41 100644 --- a/lib/screens/register.dart +++ b/lib/screens/register.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/components/register_form.dart'; +import 'package:nekoya_app/components/register_form.dart'; class Register extends StatefulWidget { const Register({Key? key}) : super(key: key); diff --git a/lib/screens/sessions.dart b/lib/screens/sessions.dart index 86d2eb1..ee7ee4b 100644 --- a/lib/screens/sessions.dart +++ b/lib/screens/sessions.dart @@ -1,10 +1,10 @@ import 'package:universal_html/html.dart' as html; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/menu.dart'; -import 'package:nekoya_flutter/components/session_box.dart'; -import 'package:nekoya_flutter/data/auth.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/menu.dart'; +import 'package:nekoya_app/components/session_box.dart'; +import 'package:nekoya_app/data/auth.dart'; class Sessions extends StatefulWidget { const Sessions({Key? key}) : super(key: key); @@ -19,7 +19,7 @@ class _SessionsState extends State { var session = await getSession(); var data = await getSessions(session); return data; - } catch(e) { + } catch (e) { return []; } } @@ -27,75 +27,81 @@ class _SessionsState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color(0xff1b1c1e), - appBar: AppBar( - title: const Text('Active Sessions'), - centerTitle: true, - backgroundColor: const Color(0xff212226), - actions: [ - IconButton( - icon: const Icon(Icons.logout), - onPressed: () { - removeSession(); - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return AlertDialog( - title: const Text('Log out', style: TextStyle(color: Colors.white),), - backgroundColor: const Color(0xff212226), - content: SingleChildScrollView( - child: ListBody( - children: const [ - Text('You have successfully logged out', style: TextStyle( - color: Colors.white - )), + backgroundColor: const Color(0xff1b1c1e), + appBar: AppBar( + title: const Text('Active Sessions'), + centerTitle: true, + backgroundColor: const Color(0xff212226), + actions: [ + IconButton( + icon: const Icon(Icons.logout), + onPressed: () { + removeSession(); + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: const Text( + 'Log out', + style: TextStyle(color: Colors.white), + ), + backgroundColor: const Color(0xff212226), + content: const SingleChildScrollView( + child: ListBody( + children: [ + Text('You have successfully logged out', + style: TextStyle(color: Colors.white)), + ], + ), + ), + actions: [ + TextButton( + child: const Text( + 'Close', + style: TextStyle(color: Colors.white), + ), + onPressed: () { + Navigator.of(context).pop(); + html.window.history.pushState(null, '', ''); + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (context) => + const Menu(initialScreen: 2))); + }, + ), ], - ), - ), - actions: [ - TextButton( - child: const Text('Close', style: TextStyle(color: Colors.white),), - onPressed: () { - Navigator.of(context).pop(); - html.window.history.pushState(null, '', ''); - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => const Menu(initialScreen: 2)) - ); - }, - ), - ], - ); - } - ); - }, - ) - ], - ), - body: FutureBuilder( - future: loadSessions(), - builder: (context, snapshot) { - if (snapshot.hasData) { - var listSessions = snapshot.data; - return ListView.builder( - itemCount: listSessions['data']!.length, - itemBuilder: (context, index) { - return SessionBox( - icon: const Icon(Icons.key, color: Colors.white, size: 50,), - ip: listSessions['data'][index]['ip'].split(', ')[0], - userAgent: listSessions['data'][index]['user_agent'], - ); + ); + }); + }, + ) + ], + ), + body: FutureBuilder( + future: loadSessions(), + builder: (context, snapshot) { + if (snapshot.hasData) { + var listSessions = snapshot.data; + return ListView.builder( + itemCount: listSessions['data']!.length, + itemBuilder: (context, index) { + return SessionBox( + icon: const Icon( + Icons.key, + color: Colors.white, + size: 50, + ), + ip: listSessions['data'][index]['ip'].split(', ')[0], + userAgent: listSessions['data'][index]['user_agent'], + ); + }); } - ); - } - return const Center( - child: CircularProgressIndicator( - color: Color(0xff8B0000), - ), - ); - } - ) - ); + return const Center( + child: CircularProgressIndicator( + color: Color(0xff8B0000), + ), + ); + })); } -} \ No newline at end of file +} diff --git a/lib/screens/transactions.dart b/lib/screens/transactions.dart index 9b69791..eef932d 100644 --- a/lib/screens/transactions.dart +++ b/lib/screens/transactions.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/api/api.dart'; -import 'package:nekoya_flutter/components/transaction_box.dart'; -import 'package:nekoya_flutter/data/auth.dart'; +import 'package:nekoya_app/api/api.dart'; +import 'package:nekoya_app/components/transaction_box.dart'; +import 'package:nekoya_app/data/auth.dart'; class Transactions extends StatefulWidget { const Transactions({Key? key}) : super(key: key); @@ -17,7 +17,7 @@ class _TransactionsState extends State { var session = await getSession(); var data = await getTransactions(session); return data; - } catch(e) { + } catch (e) { return []; } } @@ -25,46 +25,43 @@ class _TransactionsState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: const Color(0xff1b1c1e), - appBar: AppBar( - title: const Text('Transactions'), - centerTitle: true, - backgroundColor: const Color(0xff212226), - ), - body: FutureBuilder( - future: loadTransaction(), - builder: (context, snapshot) { - if (snapshot.hasData) { - var data = snapshot.data; - return ListView.builder( - itemCount: data!.length, - itemBuilder: (context, index) { - return TransactionBox( - orderId: data[index]['id'], - status: data[index]['status'], - firstName: data[index]['firstName'], - lastName: data[index]['lastName'], - phoneNumber: data[index]['phoneNumber'], - streetAddress1: data[index]['streetAddress1'], - district: data[index]['district'], - subDistrict: data[index]['subDistrict'], - province: data[index]['province'], - region: data[index]['region'], - postalCode: data[index]['postalCode'], - logistic: data[index]['logistic'], - data: data[index]['data'], - ); + backgroundColor: const Color(0xff1b1c1e), + appBar: AppBar( + title: const Text('Transactions'), + centerTitle: true, + backgroundColor: const Color(0xff212226), + ), + body: FutureBuilder( + future: loadTransaction(), + builder: (context, snapshot) { + if (snapshot.hasData) { + var data = snapshot.data; + return ListView.builder( + itemCount: data!.length, + itemBuilder: (context, index) { + return TransactionBox( + orderId: data[index]['id'], + status: data[index]['status'], + firstName: data[index]['firstName'], + lastName: data[index]['lastName'], + phoneNumber: data[index]['phoneNumber'], + streetAddress1: data[index]['streetAddress1'], + district: data[index]['district'], + subDistrict: data[index]['subDistrict'], + province: data[index]['province'], + region: data[index]['region'], + postalCode: data[index]['postalCode'], + logistic: data[index]['logistic'], + data: data[index]['data'], + ); + }); } - ); - } - return const Center( - child: CircularProgressIndicator( - color: Color(0xff8B0000), - ), - ); - } - ) - ); + return const Center( + child: CircularProgressIndicator( + color: Color(0xff8B0000), + ), + ); + })); } -} \ No newline at end of file +} diff --git a/lib/utils/navigation_auth.dart b/lib/utils/navigation_auth.dart index affb02e..12de7a6 100644 --- a/lib/utils/navigation_auth.dart +++ b/lib/utils/navigation_auth.dart @@ -1,8 +1,8 @@ import 'package:universal_html/html.dart' as html; import 'package:flutter/material.dart'; -import 'package:nekoya_flutter/data/auth.dart'; -import 'package:nekoya_flutter/screens/login.dart'; +import 'package:nekoya_app/data/auth.dart'; +import 'package:nekoya_app/screens/login.dart'; class NavigationAuth extends StatelessWidget { const NavigationAuth({Key? key, required this.route}) : super(key: key); @@ -11,26 +11,24 @@ class NavigationAuth extends StatelessWidget { @override Widget build(BuildContext context) { - return FutureBuilder( - future: checkSessionExist(), - builder: (context, snapshot) { - if (snapshot.hasData) { - var data = snapshot.data; - if (data) { - return route; + future: checkSessionExist(), + builder: (context, snapshot) { + if (snapshot.hasData) { + var data = snapshot.data; + if (data) { + return route; + } else { + html.window.history.pushState(null, '', '/#/login'); + return const Login(); + } } else { - html.window.history.pushState(null, '', '/#/login'); - return const Login(); + return const Center( + child: CircularProgressIndicator( + color: Color(0xff8B0000), + ), + ); } - } else { - return const Center( - child: CircularProgressIndicator( - color: Color(0xff8B0000), - ), - ); - } - } - ); + }); } -} \ No newline at end of file +} diff --git a/workspace.bat b/workspace.bat index 484ea70..28ac8cb 100644 --- a/workspace.bat +++ b/workspace.bat @@ -1,9 +1,9 @@ @echo off echo "=== WORKSPACE SCRIPT RUNNING ===" -mkdir nekoya_flutter -cd nekoya_flutter +mkdir nekoya_app +cd nekoya_app git clone https://gitlab.com/nekoya/app.git . flutter create . flutter pub get -flutter pub run flutter_launcher_icons_maker:main +flutter pub run flutter_launcher_icons echo "=== DONE :3 ===" \ No newline at end of file diff --git a/workspace.sh b/workspace.sh index e418802..09c7e7d 100644 --- a/workspace.sh +++ b/workspace.sh @@ -1,8 +1,8 @@ echo "=== WORKSPACE SCRIPT RUNNING ===" -mkdir nekoya_flutter -cd nekoya_flutter +mkdir nekoya_app +cd nekoya_app git clone https://gitlab.com/nekoya/app.git . flutter create . flutter pub get -flutter pub run flutter_launcher_icons_maker:main +flutter pub run flutter_launcher_icons echo "=== DONE :3 ===" \ No newline at end of file