From a7c3ea5922a4408de2435e2e4d4b3282729781b3 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 22:40:58 +0700 Subject: [PATCH 01/18] Add flutter web plugins to dependencies --- pubspec.lock | 2 +- pubspec.yaml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pubspec.lock b/pubspec.lock index 67cc3d7..7f02bcc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -180,7 +180,7 @@ packages: source: sdk version: "0.0.0" flutter_web_plugins: - dependency: transitive + dependency: "direct main" description: flutter source: sdk version: "0.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 5a0ff0f..1ed11aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,8 @@ dependencies: sdk: flutter flutter_form_builder: ^7.1.1 flutter_launcher_icons_maker: ^0.10.2 + flutter_web_plugins: + sdk: flutter intl: ^0.17.0 lottie: ^1.3.0 shared_preferences: ^2.0.13 From e6ec1a13ef58daf9782aa8a357a5b2f0d2ee19ef Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 22:41:17 +0700 Subject: [PATCH 02/18] Add url strategy support --- lib/main.dart | 5 +++-- lib/utils/url_strategy.dart | 1 + lib/utils/url_strategy_noop.dart | 3 +++ lib/utils/url_strategy_web.dart | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 lib/utils/url_strategy.dart create mode 100644 lib/utils/url_strategy_noop.dart create mode 100644 lib/utils/url_strategy_web.dart diff --git a/lib/main.dart b/lib/main.dart index 1a340b5..27af3d4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,11 +4,12 @@ import 'package:page_transition/page_transition.dart'; import 'package:animated_splash_screen/animated_splash_screen.dart'; import 'package:nekoya_flutter/components/menu.dart'; +import 'package:nekoya_flutter/utils/url_strategy.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); - SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) - .then((_) { + SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then((_) { + usePathUrlStrategy(); runApp(const Nekoya()); }); } diff --git a/lib/utils/url_strategy.dart b/lib/utils/url_strategy.dart new file mode 100644 index 0000000..c86a8de --- /dev/null +++ b/lib/utils/url_strategy.dart @@ -0,0 +1 @@ +export 'url_strategy_noop.dart' if (dart.library.html) 'url_strategy_web.dart'; \ No newline at end of file diff --git a/lib/utils/url_strategy_noop.dart b/lib/utils/url_strategy_noop.dart new file mode 100644 index 0000000..5295ed3 --- /dev/null +++ b/lib/utils/url_strategy_noop.dart @@ -0,0 +1,3 @@ +void usePathUrlStrategy() { + // noop +} \ No newline at end of file diff --git a/lib/utils/url_strategy_web.dart b/lib/utils/url_strategy_web.dart new file mode 100644 index 0000000..a384516 --- /dev/null +++ b/lib/utils/url_strategy_web.dart @@ -0,0 +1,5 @@ +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +void usePathUrlStrategy() { + setUrlStrategy(PathUrlStrategy()); +} \ No newline at end of file From 8f6ae35e4db4aff2e8cc10768670d83dc0b7454c Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:29:00 +0700 Subject: [PATCH 03/18] Add direct path support to access some pages --- lib/main.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 27af3d4..0b0eec4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,8 @@ import 'package:flutter/material.dart'; import 'package:page_transition/page_transition.dart'; import 'package:animated_splash_screen/animated_splash_screen.dart'; +import 'package:nekoya_flutter/screens/login.dart'; +import 'package:nekoya_flutter/screens/register.dart'; import 'package:nekoya_flutter/components/menu.dart'; import 'package:nekoya_flutter/utils/url_strategy.dart'; @@ -37,6 +39,14 @@ class _NekoyaState extends State<Nekoya> { nextScreen: const Menu(initialScreen: 2,), ), debugShowCheckedModeBanner: false, + initialRoute: '', + routes: { + '' : (context) => const Menu(initialScreen: 2,), + '/login': (context) => const Login(), + '/register': (context) => const Register(), + '/products' : (context) => const Menu(initialScreen: 1,), + '/cart' : (context) => const Menu(initialScreen: 3,), + }, ); } } \ No newline at end of file From 4e23c345a2d44b7ff52021e410bce5daf5606056 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:29:43 +0700 Subject: [PATCH 04/18] Update login routing from push to pushNamed --- lib/components/checkout_form.dart | 5 +---- lib/components/forgot_pass_body.dart | 3 +-- lib/components/menu.dart | 6 ++---- lib/components/otp_body.dart | 3 +-- lib/components/register_form.dart | 5 +---- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/components/checkout_form.dart b/lib/components/checkout_form.dart index cd041eb..503aa51 100644 --- a/lib/components/checkout_form.dart +++ b/lib/components/checkout_form.dart @@ -268,10 +268,7 @@ class _CheckoutFormState extends State<CheckoutForm> { } }); } else { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const Login())); + Navigator.pushNamed(context, '/login'); } }); }, diff --git a/lib/components/forgot_pass_body.dart b/lib/components/forgot_pass_body.dart index fe02014..368ce32 100644 --- a/lib/components/forgot_pass_body.dart +++ b/lib/components/forgot_pass_body.dart @@ -80,8 +80,7 @@ class _ForgotPassBodyState extends State<ForgotPassBody> { borderRadius: BorderRadius.circular(18.0), side: const BorderSide(color: Colors.red)))), onPressed: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => const Login())); + Navigator.pushNamed(context, '/login'); }, child: const Text( 'Back to Login', diff --git a/lib/components/menu.dart b/lib/components/menu.dart index c643307..92d0ba4 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -68,8 +68,7 @@ class _MenuState extends State<Menu> { _selectedWidget = const Sessions(); } else { _selectedIndex = oldSelectedIndex; - Navigator.push(context, - MaterialPageRoute(builder: (context) => const Login())); + Navigator.pushNamed(context, '/login'); } }); } else if (index == 1) { @@ -84,8 +83,7 @@ class _MenuState extends State<Menu> { _selectedWidget = const Transactions(); } else { _selectedIndex = oldSelectedIndex; - Navigator.push(context, - MaterialPageRoute(builder: (context) => const Login())); + Navigator.pushNamed(context, '/login'); } }); } diff --git a/lib/components/otp_body.dart b/lib/components/otp_body.dart index c84bca8..19f38ad 100644 --- a/lib/components/otp_body.dart +++ b/lib/components/otp_body.dart @@ -251,8 +251,7 @@ class _OtpBodyState extends State<OtpBody> { borderRadius: BorderRadius.circular(18.0), side: const BorderSide(color: Colors.red)))), onPressed: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => const Login())); + Navigator.pushNamed(context, '/login'); }, child: const Text( 'Verify', diff --git a/lib/components/register_form.dart b/lib/components/register_form.dart index f541454..2f5a6fc 100644 --- a/lib/components/register_form.dart +++ b/lib/components/register_form.dart @@ -156,10 +156,7 @@ class RegisterFormState extends State<RegisterForm> { ), onPressed: () { Navigator.pop(context); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const Login())); + Navigator.pushNamed(context, '/login'); }, ), ], From a4bcb7abe702a2658b2783cf0e2245360e345fc1 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:30:00 +0700 Subject: [PATCH 05/18] update register routing from push to pushNamed --- lib/components/login_form.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/components/login_form.dart b/lib/components/login_form.dart index f0b139b..6eb4a05 100644 --- a/lib/components/login_form.dart +++ b/lib/components/login_form.dart @@ -168,8 +168,7 @@ class LoginFormState extends State<LoginForm> { return GestureDetector( onTap: () { Navigator.pop(context); - Navigator.push( - context, MaterialPageRoute(builder: (context) => const Register())); + Navigator.pushNamed(context, '/register'); }, child: RichText( text: const TextSpan( From 2af64af8b818a06730005e8bf589052ea4720507 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:30:17 +0700 Subject: [PATCH 06/18] update menu --- lib/components/menu.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 92d0ba4..6045452 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -26,9 +26,9 @@ class _MenuState extends State<Menu> { @override void initState() { if (widget.initialScreen == 0) { - _selectedWidget = const Login(); + _selectedWidget = const Sessions(); } else if (widget.initialScreen == 1) { - _selectedWidget = const Register(); + _selectedWidget = const HomeScreen(); } else if (widget.initialScreen == 2) { _selectedWidget = const Products(); } else if (widget.initialScreen == 3) { From f037b69b4768572e65bb9828ec383e19de4cb20c Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:32:05 +0700 Subject: [PATCH 07/18] Remove unused import --- lib/components/checkout_form.dart | 1 - lib/components/details_screen.dart | 1 - lib/components/forgot_pass_body.dart | 1 - lib/components/login_form.dart | 1 - lib/components/menu.dart | 2 -- lib/components/otp_body.dart | 1 - lib/components/product_detail.dart | 1 - lib/components/register_form.dart | 1 - 8 files changed, 9 deletions(-) diff --git a/lib/components/checkout_form.dart b/lib/components/checkout_form.dart index 503aa51..40cebdc 100644 --- a/lib/components/checkout_form.dart +++ b/lib/components/checkout_form.dart @@ -5,7 +5,6 @@ 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_flutter/screens/login.dart'; import 'package:nekoya_flutter/screens/payment.dart'; class CheckoutForm extends StatefulWidget { diff --git a/lib/components/details_screen.dart b/lib/components/details_screen.dart index da1de94..065172e 100644 --- a/lib/components/details_screen.dart +++ b/lib/components/details_screen.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import '../utils/utils.dart'; import 'package:nekoya_flutter/screens/productcoba.dart'; -import 'package:nekoya_flutter/screens/products.dart'; import 'package:nekoya_flutter/components/color_dot.dart'; diff --git a/lib/components/forgot_pass_body.dart b/lib/components/forgot_pass_body.dart index 368ce32..ad12597 100644 --- a/lib/components/forgot_pass_body.dart +++ b/lib/components/forgot_pass_body.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; -import 'package:nekoya_flutter/screens/login.dart'; import 'package:nekoya_flutter/screens/otp.dart'; class ForgotPassBody extends StatefulWidget { diff --git a/lib/components/login_form.dart b/lib/components/login_form.dart index 6eb4a05..3969ec2 100644 --- a/lib/components/login_form.dart +++ b/lib/components/login_form.dart @@ -5,7 +5,6 @@ import 'package:nekoya_flutter/api/api.dart'; import 'package:nekoya_flutter/components/login_error.dart'; import 'package:nekoya_flutter/components/menu.dart'; import 'package:nekoya_flutter/data/auth.dart'; -import 'package:nekoya_flutter/screens/register.dart'; import 'package:nekoya_flutter/utils/utils.dart'; class LoginForm extends StatefulWidget { diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 6045452..9096e46 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -2,10 +2,8 @@ import 'package:flutter/material.dart'; import 'dart:math' as math; import 'package:nekoya_flutter/data/auth.dart'; -import 'package:nekoya_flutter/screens/login.dart'; import 'package:nekoya_flutter/screens/products.dart'; import 'package:nekoya_flutter/screens/cart.dart'; -import 'package:nekoya_flutter/screens/register.dart'; import 'package:nekoya_flutter/screens/sessions.dart'; import 'package:nekoya_flutter/screens/transactions.dart'; import 'package:nekoya_flutter/screens/home_screen.dart'; diff --git a/lib/components/otp_body.dart b/lib/components/otp_body.dart index 19f38ad..291d8a9 100644 --- a/lib/components/otp_body.dart +++ b/lib/components/otp_body.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:lottie/lottie.dart'; -import 'package:nekoya_flutter/screens/login.dart'; class OtpBody extends StatefulWidget { const OtpBody({Key? key}) : super(key: key); diff --git a/lib/components/product_detail.dart b/lib/components/product_detail.dart index 74032f2..637aa6e 100644 --- a/lib/components/product_detail.dart +++ b/lib/components/product_detail.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:nekoya_flutter/api/api.dart'; import 'package:nekoya_flutter/data/cart.dart'; -import 'package:nekoya_flutter/screens/productcoba.dart'; import 'package:nekoya_flutter/utils/utils.dart'; Widget makeDismissible({required context, required Widget child}) => diff --git a/lib/components/register_form.dart b/lib/components/register_form.dart index 2f5a6fc..6753962 100644 --- a/lib/components/register_form.dart +++ b/lib/components/register_form.dart @@ -5,7 +5,6 @@ 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_flutter/screens/login.dart'; class RegisterForm extends StatefulWidget { const RegisterForm({Key? key}) : super(key: key); From fe5b7cd35eb7a7c8155a7bb91eeb3930615ac06f Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:43:46 +0700 Subject: [PATCH 08/18] rename source file --- lib/components/{Category.dart => _category.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/components/{Category.dart => _category.dart} (100%) diff --git a/lib/components/Category.dart b/lib/components/_category.dart similarity index 100% rename from lib/components/Category.dart rename to lib/components/_category.dart From 6829342c99cd70fab16b7ad62b3a5dbe2214c50d Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:44:03 +0700 Subject: [PATCH 09/18] Cleanup code --- lib/components/_category.dart | 2 +- lib/components/categories.dart | 8 ++--- lib/components/details_screen.dart | 2 +- lib/components/new_arrival_products.dart | 12 +++---- lib/components/otp_body.dart | 46 ++++++++++++------------ lib/components/popular_products.dart | 10 +++--- lib/components/product_card.dart | 2 +- lib/screens/home_screen.dart | 4 +-- lib/screens/productcoba.dart | 2 +- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/components/_category.dart b/lib/components/_category.dart index b72aa6a..0ccb5e6 100644 --- a/lib/components/_category.dart +++ b/lib/components/_category.dart @@ -4,7 +4,7 @@ class Category { Category({required this.icon, required this.title}); } -List<Category> demo_categories = [ +List<Category> demoCategories = [ Category( icon: "assets/icons/dress.svg", title: "Dress", diff --git a/lib/components/categories.dart b/lib/components/categories.dart index 535911a..5eefab9 100644 --- a/lib/components/categories.dart +++ b/lib/components/categories.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:nekoya_flutter/components/Category.dart'; +import 'package:nekoya_flutter/components/_category.dart'; import '../utils/utils.dart'; @@ -15,10 +15,10 @@ class Categories extends StatelessWidget { height: 84, child: ListView.separated( scrollDirection: Axis.horizontal, - itemCount: demo_categories.length, + itemCount: demoCategories.length, itemBuilder: (context, index) => CategoryCard( - icon: demo_categories[index].icon, - title: demo_categories[index].title, + icon: demoCategories[index].icon, + title: demoCategories[index].title, press: () {}, ), separatorBuilder: (context, index) => diff --git a/lib/components/details_screen.dart b/lib/components/details_screen.dart index 065172e..c0d9422 100644 --- a/lib/components/details_screen.dart +++ b/lib/components/details_screen.dart @@ -61,7 +61,7 @@ class DetailsScreen extends StatelessWidget { ), const SizedBox(width: defaultPadding), Text( - "\$" + product.price.toString(), + "\$${product.price}", style: Theme.of(context).textTheme.headline6, ), ], diff --git a/lib/components/new_arrival_products.dart b/lib/components/new_arrival_products.dart index 11dddb4..47f5b12 100644 --- a/lib/components/new_arrival_products.dart +++ b/lib/components/new_arrival_products.dart @@ -28,20 +28,20 @@ class NewArrivalProducts extends StatelessWidget { scrollDirection: Axis.horizontal, child: Row( children: List.generate( - demo_product.length, + demoProduct.length, (index) => Padding( padding: const EdgeInsets.only(right: defaultPadding), child: ProductCard( - title: demo_product[index].title, - image: demo_product[index].image, - price: demo_product[index].price, - bgColor: demo_product[index].bgColor, + title: demoProduct[index].title, + image: demoProduct[index].image, + price: demoProduct[index].price, + bgColor: demoProduct[index].bgColor, press: () { Navigator.push( context, MaterialPageRoute( builder: (context) => - DetailsScreen(product: demo_product[index]), + DetailsScreen(product: demoProduct[index]), )); }, ), diff --git a/lib/components/otp_body.dart b/lib/components/otp_body.dart index 291d8a9..7ae8aa6 100644 --- a/lib/components/otp_body.dart +++ b/lib/components/otp_body.dart @@ -19,8 +19,8 @@ class _OtpBodyState extends State<OtpBody> { child: Lottie.asset('assets/lottieanims/otp.json'), ), Container( - padding: EdgeInsets.only(top: 15), - child: Text( + padding: const EdgeInsets.only(top: 15), + child: const Text( 'A String of OTP Code Has Been Sent to 08080808080808', textAlign: TextAlign.center, style: TextStyle(fontSize: 15, color: Colors.white), @@ -28,7 +28,7 @@ class _OtpBodyState extends State<OtpBody> { ), Form( child: Container( - padding: EdgeInsets.only(top: 15), + padding: const EdgeInsets.only(top: 15), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, @@ -44,18 +44,18 @@ class _OtpBodyState extends State<OtpBody> { onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); - } else if (value.length == 0) { + } else if (value.isEmpty) { FocusScope.of(context).previousFocus(); } }, onSaved: (pin1) {}, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: "0", focusColor: Colors.white, hintStyle: TextStyle(color: Colors.white), ), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(1), @@ -75,18 +75,18 @@ class _OtpBodyState extends State<OtpBody> { onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); - } else if (value.length == 0) { + } else if (value.isEmpty) { FocusScope.of(context).previousFocus(); } }, onSaved: (pin1) {}, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: "0", focusColor: Colors.white, hintStyle: TextStyle(color: Colors.white), ), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(1), @@ -106,18 +106,18 @@ class _OtpBodyState extends State<OtpBody> { onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); - } else if (value.length == 0) { + } else if (value.isEmpty) { FocusScope.of(context).previousFocus(); } }, onSaved: (pin1) {}, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: "0", focusColor: Colors.white, hintStyle: TextStyle(color: Colors.white), ), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(1), @@ -137,18 +137,18 @@ class _OtpBodyState extends State<OtpBody> { onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); - } else if (value.length == 0) { + } else if (value.isEmpty) { FocusScope.of(context).previousFocus(); } }, onSaved: (pin1) {}, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: "0", focusColor: Colors.white, hintStyle: TextStyle(color: Colors.white), ), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(1), @@ -168,18 +168,18 @@ class _OtpBodyState extends State<OtpBody> { onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); - } else if (value.length == 0) { + } else if (value.isEmpty) { FocusScope.of(context).previousFocus(); } }, onSaved: (pin1) {}, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: "0", focusColor: Colors.white, hintStyle: TextStyle(color: Colors.white), ), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(1), @@ -199,18 +199,18 @@ class _OtpBodyState extends State<OtpBody> { onChanged: (value) { if (value.length == 1) { FocusScope.of(context).nextFocus(); - } else if (value.length == 0) { + } else if (value.isEmpty) { FocusScope.of(context).previousFocus(); } }, onSaved: (pin1) {}, - decoration: InputDecoration( + decoration: const InputDecoration( hintText: "0", focusColor: Colors.white, hintStyle: TextStyle(color: Colors.white), ), textAlign: TextAlign.center, - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), keyboardType: TextInputType.number, inputFormatters: [ LengthLimitingTextInputFormatter(1), @@ -223,12 +223,12 @@ class _OtpBodyState extends State<OtpBody> { ), )), Container( - padding: EdgeInsets.only(top: 15, bottom: 15), + padding: const EdgeInsets.only(top: 15, bottom: 15), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text( + const Text( "didn't get the code? \t", style: TextStyle(color: Colors.white), ), diff --git a/lib/components/popular_products.dart b/lib/components/popular_products.dart index f22d170..a2a3336 100644 --- a/lib/components/popular_products.dart +++ b/lib/components/popular_products.dart @@ -27,14 +27,14 @@ class PopularProducts extends StatelessWidget { scrollDirection: Axis.horizontal, child: Row( children: List.generate( - demo_product.length, + demoProduct.length, (index) => Padding( padding: const EdgeInsets.only(right: defaultPadding), child: ProductCard( - title: demo_product[index].title, - image: demo_product[index].image, - price: demo_product[index].price, - bgColor: demo_product[index].bgColor, + title: demoProduct[index].title, + image: demoProduct[index].image, + price: demoProduct[index].price, + bgColor: demoProduct[index].bgColor, press: () {}, ), ), diff --git a/lib/components/product_card.dart b/lib/components/product_card.dart index 90d7f3f..36a1254 100644 --- a/lib/components/product_card.dart +++ b/lib/components/product_card.dart @@ -52,7 +52,7 @@ class ProductCard extends StatelessWidget { ), const SizedBox(width: defaultPadding / 4), Text( - "\$" + price.toString(), + "\$$price", style: Theme.of(context).textTheme.subtitle2, ), ], diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index bc5707f..a270c74 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -22,8 +22,8 @@ class HomeScreen extends StatelessWidget { ), title: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ - const SizedBox(width: defaultPadding / 2), + children: const [ + SizedBox(width: defaultPadding / 2), Text( "Nekoya", style: TextStyle(fontSize: 20.0, color: Colors.white), diff --git a/lib/screens/productcoba.dart b/lib/screens/productcoba.dart index 3de3428..0e6bb91 100644 --- a/lib/screens/productcoba.dart +++ b/lib/screens/productcoba.dart @@ -13,7 +13,7 @@ class Product { }); } -List<Product> demo_product = [ +List<Product> demoProduct = [ Product( image: "assets/Product_2.webp", title: "Long Sleeve Shirts", From f27e339049b4813c02de31ca8acf4954a0b985fd Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:49:44 +0700 Subject: [PATCH 10/18] Add universal html to dependencies --- pubspec.lock | 28 ++++++++++++++++++++++++++++ pubspec.yaml | 6 +++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index 7f02bcc..2f726a9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -92,6 +92,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.1" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.1" cupertino_icons: dependency: "direct main" description: @@ -184,6 +191,13 @@ packages: description: flutter source: sdk version: "0.0.0" + html: + dependency: transitive + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.15.0" http: dependency: transitive description: @@ -511,6 +525,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + universal_html: + dependency: "direct main" + description: + name: universal_html + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + universal_io: + dependency: transitive + description: + name: universal_io + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" uuid: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1ed11aa..ee80913 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,7 +28,6 @@ environment: # versions available, run `flutter pub outdated`. dependencies: animated_splash_screen: ^1.2.0 - page_transition: ^2.0.5 cached_network_image: ^3.2.0 cupertino_icons: ^1.0.2 dio: ^4.0.6 @@ -36,12 +35,14 @@ dependencies: sdk: flutter flutter_form_builder: ^7.1.1 flutter_launcher_icons_maker: ^0.10.2 + flutter_svg: ^1.0.3 flutter_web_plugins: sdk: flutter intl: ^0.17.0 lottie: ^1.3.0 + page_transition: ^2.0.5 shared_preferences: ^2.0.13 - flutter_svg: ^1.0.3 + universal_html: ^2.0.8 dev_dependencies: flutter_lints: ^2.0.1 @@ -89,6 +90,5 @@ flutter: weight: 700 - asset: assets/fonts/Gordita_Light.otf weight: 300 - # # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages From 7fe9cb61d3c7c4383cf0411b212e73f5d33bc0b0 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:50:20 +0700 Subject: [PATCH 11/18] Add change url path ability to menu --- lib/components/menu.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 9096e46..315eaeb 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -1,5 +1,6 @@ -import 'package:flutter/material.dart'; 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'; @@ -70,10 +71,12 @@ class _MenuState extends State<Menu> { } }); } else if (index == 1) { + html.window.history.pushState(null, '', '/products'); _selectedWidget = const HomeScreen(); } else if (index == 2) { _selectedWidget = const Products(); } else if (index == 3) { + html.window.history.pushState(null, '', '/cart'); _selectedWidget = const Cart(); } else if (index == 4) { checkSessionExist().then((isLoggedIn) { From abe36050f5de641380c633bde517992fa6e19093 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:51:07 +0700 Subject: [PATCH 12/18] update menu --- lib/components/menu.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 315eaeb..3bcab03 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -27,9 +27,9 @@ class _MenuState extends State<Menu> { if (widget.initialScreen == 0) { _selectedWidget = const Sessions(); } else if (widget.initialScreen == 1) { - _selectedWidget = const HomeScreen(); - } else if (widget.initialScreen == 2) { _selectedWidget = const Products(); + } else if (widget.initialScreen == 2) { + _selectedWidget = const HomeScreen(); } else if (widget.initialScreen == 3) { _selectedWidget = const Cart(); } else if (widget.initialScreen == 4) { From ba10a18d8b7ca954bc08cfe2b65f92ed96a30925 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:52:16 +0700 Subject: [PATCH 13/18] Rename class from HomeScreen to Home --- lib/components/menu.dart | 4 ++-- lib/screens/home_screen.dart | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 3bcab03..bf080c8 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -29,7 +29,7 @@ class _MenuState extends State<Menu> { } else if (widget.initialScreen == 1) { _selectedWidget = const Products(); } else if (widget.initialScreen == 2) { - _selectedWidget = const HomeScreen(); + _selectedWidget = const Home(); } else if (widget.initialScreen == 3) { _selectedWidget = const Cart(); } else if (widget.initialScreen == 4) { @@ -72,7 +72,7 @@ class _MenuState extends State<Menu> { }); } else if (index == 1) { html.window.history.pushState(null, '', '/products'); - _selectedWidget = const HomeScreen(); + _selectedWidget = const Home(); } else if (index == 2) { _selectedWidget = const Products(); } else if (index == 3) { diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index a270c74..d99ef03 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -7,8 +7,8 @@ import 'package:nekoya_flutter/components/new_arrival_products.dart'; import 'package:nekoya_flutter/components/popular_products.dart'; import 'package:nekoya_flutter/components/search_form.dart'; -class HomeScreen extends StatelessWidget { - const HomeScreen({Key? key}) : super(key: key); +class Home extends StatelessWidget { + const Home({Key? key}) : super(key: key); @override Widget build(BuildContext context) { From f02f2f5d5bbd72bb92a100a1e268ae9a01668f53 Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sat, 14 May 2022 23:52:53 +0700 Subject: [PATCH 14/18] Rename source file from home_screen to home --- lib/screens/{home_screen.dart => home.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/screens/{home_screen.dart => home.dart} (100%) diff --git a/lib/screens/home_screen.dart b/lib/screens/home.dart similarity index 100% rename from lib/screens/home_screen.dart rename to lib/screens/home.dart From 43075070975d5fe6002e3e6181ea548987e861fe Mon Sep 17 00:00:00 2001 From: Moe <moe@chocola.dev> Date: Sun, 15 May 2022 00:00:43 +0700 Subject: [PATCH 15/18] Update menu --- lib/components/menu.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/components/menu.dart b/lib/components/menu.dart index bf080c8..6174107 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -7,7 +7,7 @@ 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_screen.dart'; +import 'package:nekoya_flutter/screens/home.dart'; class Menu extends StatefulWidget { const Menu({Key? key, required this.initialScreen}) : super(key: key); From 404b394495ee350362392805dd2ff1b9f0dbfc81 Mon Sep 17 00:00:00 2001 From: Matthew Patrick <Matthew.535200018@stu.untar.ac.id> Date: Sun, 15 May 2022 00:16:42 +0700 Subject: [PATCH 16/18] menu - Fixed order on App NavBar --- lib/components/menu.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/menu.dart b/lib/components/menu.dart index 6174107..c4f891b 100644 --- a/lib/components/menu.dart +++ b/lib/components/menu.dart @@ -72,9 +72,9 @@ class _MenuState extends State<Menu> { }); } else if (index == 1) { html.window.history.pushState(null, '', '/products'); - _selectedWidget = const Home(); - } else if (index == 2) { _selectedWidget = const Products(); + } else if (index == 2) { + _selectedWidget = const Home(); } else if (index == 3) { html.window.history.pushState(null, '', '/cart'); _selectedWidget = const Cart(); From 2052f7b77dec74ac52cd54f767e963b9a7ce6d0b Mon Sep 17 00:00:00 2001 From: Matthew Patrick <Matthew.535200018@stu.untar.ac.id> Date: Sun, 15 May 2022 00:19:49 +0700 Subject: [PATCH 17/18] home - Remove icons on top appbar --- lib/screens/home.dart | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/lib/screens/home.dart b/lib/screens/home.dart index d99ef03..64b4f8e 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -15,28 +15,9 @@ class Home extends StatelessWidget { return Scaffold( backgroundColor: const Color(0xff1b1c1e), appBar: AppBar( + title: const Text('Nekoya'), + centerTitle: true, backgroundColor: const Color(0xff212226), - leading: IconButton( - onPressed: () {}, - icon: SvgPicture.asset("assets/icons/menu.svg"), - ), - title: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: const [ - SizedBox(width: defaultPadding / 2), - Text( - "Nekoya", - style: TextStyle(fontSize: 20.0, color: Colors.white), - ), - ], - ), - actions: [ - IconButton( - icon: SvgPicture.asset("assets/icons/Notification.svg"), - color: Colors.white, - onPressed: () {}, - ), - ], ), body: SingleChildScrollView( physics: const BouncingScrollPhysics( From 362438f97b7682ba86afdf7a512c9a536ed3be65 Mon Sep 17 00:00:00 2001 From: Matthew Patrick <Matthew.535200018@stu.untar.ac.id> Date: Sun, 15 May 2022 00:20:31 +0700 Subject: [PATCH 18/18] Removed unused assets --- assets/icons/Notification.svg | 5 ----- assets/icons/menu.svg | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 assets/icons/Notification.svg delete mode 100644 assets/icons/menu.svg diff --git a/assets/icons/Notification.svg b/assets/icons/Notification.svg deleted file mode 100644 index bae3424..0000000 --- a/assets/icons/Notification.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg"> -<g opacity="0.3"> -<path fill-rule="evenodd" clip-rule="evenodd" d="M19.9025 9.68574C19.9025 10.985 20.2441 11.7509 20.9959 12.6334C21.5656 13.2835 21.7476 14.1181 21.7476 15.0236C21.7476 15.928 21.452 16.7865 20.8599 17.4836C20.0846 18.3192 18.9913 18.8527 17.8754 18.9454C16.2584 19.084 14.6404 19.2007 13.0009 19.2007C11.3604 19.2007 9.74343 19.1309 8.12644 18.9454C7.00958 18.8527 5.91625 18.3192 5.14202 17.4836C4.54984 16.7865 4.25323 15.928 4.25323 15.0236C4.25323 14.1181 4.43631 13.2835 5.00497 12.6334C5.78022 11.7509 6.09932 10.985 6.09932 9.68574V9.245C6.09932 7.50497 6.53093 6.36717 7.41971 5.25334C8.74112 3.62896 10.8593 2.65475 12.9549 2.65475H13.047C15.1876 2.65475 17.3743 3.67585 18.6732 5.37004C19.5159 6.46095 19.9025 7.55081 19.9025 9.245V9.68574ZM9.98949 21.339C9.98949 20.8181 10.4651 20.5795 10.9049 20.4774C11.4193 20.368 14.5541 20.368 15.0685 20.4774C15.5083 20.5795 15.9839 20.8181 15.9839 21.339C15.9583 21.835 15.6689 22.2747 15.269 22.5539C14.7505 22.9603 14.1419 23.2177 13.5058 23.3104C13.1539 23.3562 12.8082 23.3573 12.4687 23.3104C11.8315 23.2177 11.2229 22.9603 10.7054 22.5529C10.3045 22.2747 10.0151 21.835 9.98949 21.339Z" fill="#1C1A19"/> -</g> -</svg> diff --git a/assets/icons/menu.svg b/assets/icons/menu.svg deleted file mode 100644 index 8433c33..0000000 --- a/assets/icons/menu.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="29" height="18" viewBox="0 0 29 18" fill="none" xmlns="http://www.w3.org/2000/svg"> -<line x1="1.5" y1="1" x2="27.0442" y2="1" stroke="black" stroke-width="2" stroke-linecap="round"/> -<line x1="1.5" y1="8.55573" x2="19.7285" y2="8.55573" stroke="black" stroke-width="2" stroke-linecap="round"/> -<line x1="1.5" y1="16.3913" x2="13.2721" y2="16.3913" stroke="black" stroke-width="2" stroke-linecap="round"/> -</svg>