From 7f0cef4b2382e00e79f86b42e84bd10984307693 Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Tue, 30 Apr 2024 15:58:53 +0300 Subject: [PATCH] Created screens --- .vscode/settings.json | 3 + assets/logo.png | Bin 0 -> 2309 bytes lib/main.dart | 290 +++++++++++++++++++++++------------------- pubspec.yaml | 2 + web/css/styles.css | 4 +- 5 files changed, 166 insertions(+), 133 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 assets/logo.png diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..23fd35f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..4e1c7e8309ad5ed54209458ec4a0b7a4056cbf82 GIT binary patch literal 2309 zcma);i#rnx1I2j>Eu#>bTox&Yl609#*4PMhS!UKKi7@xv(}k9IB)qv_+myy!#}Fa% zR%9+URuf_k%_U7z*nEBe!TUVtoZoZ)f^*2uPDmgC1dx!B0NSAtu75cFf6Gbz$(_Lm zP=9d8*#Tp-y}d0dDfy>4Iy$D1L z$BwnNHD6!f?(Xh^fq|Bmmc_+Ib#-+h5U8c4B@_x%Q&VX)T2fMysi~>0t!-{@Za_f5 z_3PIu6bgsKDJUrL^z>vf7!U|#czD>)&o41CalV}el#r0KvO`#7VvCoG1M;ZQ-S;Sn z^1rDcKBsbnuN>LlmYvk|efb3Uo>hP!N;z#NU&$_FzM=AT`Z(QF@6^_p~%09jQ9`!txn zdkJp->>qjUVX8md82iH9skpy{%l@U} zYG#6SSi?-_FLxs4(Yvxms29+)UzY!f_V$wv*K8=q!NKEDuHB3IObNBQ41HT&EL@*K zniZ>?L@2(kNmP5~93pYIgI~sUJ4Ud%zf1F5w5!gG!>J{wguZpv?&Jn1#rCgB4rr+5 z@aaS1FStY}Vp{*SO&fHfGOiWP*C}sf6;<2HL4Ndh1WIbd5wIEN8*cA^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6s(*A)M;!VZ)qBMkXFim#53w$ zlA6d97L{H=o|(x!;w(jj=yQqRu~w(;n`Z8~>xjMBGk7J)$2_o_U;ao+d xnc!PDwFCwtqs@@{&z+-P7h(T>+)>Ca+4!h*Rt3n&>Ccmqu(NSO)WR<%{SV3hYcK!+ literal 0 HcmV?d00001 diff --git a/lib/main.dart b/lib/main.dart index 8aae45c..1ef9f15 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,7 @@ void main() { runApp(const MyApp()); } -enum DemoScreen { counter, textField } +enum GymLinkScreen { mainPage, basketPage, historyPage } class MyApp extends StatefulWidget { const MyApp({super.key}); @@ -20,9 +20,8 @@ class MyApp extends StatefulWidget { @js.JSExport() class _MyAppState extends State { - final _streanController = StreamController.broadcast(); - DemoScreen _currentDemoScreen = DemoScreen.counter; - int _counterScreenCount = 0; + final _streamController = StreamController.broadcast(); + GymLinkScreen _currentGymLinkScreen = GymLinkScreen.mainPage; bool _isLoading = true; @override @@ -35,39 +34,19 @@ class _MyAppState extends State { @override void dispose() { - _streanController.close(); + _streamController.close(); super.dispose(); } - @js.JSExport() - void increment() { - if (_currentDemoScreen == DemoScreen.counter) { - setState(() { - _counterScreenCount++; - _streanController.add(null); - }); - } - } - - @js.JSExport() - void addHandler(void Function() handler) { - _streanController.stream.listen((event) { - handler(); - }); - } - - @js.JSExport() - int get count => _counterScreenCount; - @override Widget build(BuildContext context) { return MaterialApp( - title: 'Aboba app', + title: 'GymLink Module', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.red), ), debugShowCheckedModeBanner: false, - home: demoScreenRouter(_currentDemoScreen), + home: gymLinkScreenRouter(_currentGymLinkScreen), ); } @@ -80,147 +59,196 @@ class _MyAppState extends State { } } - Widget demoScreenRouter(DemoScreen which) { + Widget gymLinkScreenRouter(GymLinkScreen which) { switch (which) { - case DemoScreen.counter: - return CounterDemo( + case GymLinkScreen.mainPage: + return MainPage( title: 'Counter', - numToDisplay: _counterScreenCount, - incrementHandler: increment, - isLoading: _isLoading); - case DemoScreen.textField: - return const TextFieldDemo(title: 'Nasdfs'); + isLoading: _isLoading, + changeGymLinkScreenTo: changeGymLinkScreenTo); + case GymLinkScreen.basketPage: + return BasketPage(changeGymLinkScreenTo: changeGymLinkScreenTo); + case GymLinkScreen.historyPage: + return HistoryPage(changeGymLinkScreenTo: changeGymLinkScreenTo); } } @js.JSExport() - void changeDemoScreenTo(String screenString) { + void changeGymLinkScreenTo(String screenString) { setState(() { switch (screenString) { - case 'counter': - _currentDemoScreen = DemoScreen.counter; + case 'main': + _currentGymLinkScreen = GymLinkScreen.mainPage; break; - case 'textField': - _currentDemoScreen = DemoScreen.textField; + case 'basket': + _currentGymLinkScreen = GymLinkScreen.basketPage; + break; + case 'history': + _currentGymLinkScreen = GymLinkScreen.historyPage; break; } }); } } -class CounterDemo extends StatefulWidget { +class MainPage extends StatefulWidget { final String title; - final int numToDisplay; - final VoidCallback incrementHandler; final bool isLoading; + final void Function(String) changeGymLinkScreenTo; - const CounterDemo( + const MainPage( {super.key, required this.title, - required this.numToDisplay, - required this.incrementHandler, - required this.isLoading}); + required this.isLoading, + required this.changeGymLinkScreenTo}); @override - State createState() => _CounterDemoState(); + State createState() => _MainPageState(); } -class _CounterDemoState extends State { +class _MainPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: widget.isLoading - ? null - : AppBar( - title: Row( - children: [ - Expanded( - child: TextField( - decoration: InputDecoration( - hintText: 'Search', - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(10), - ), - suffixIcon: const Icon( - Icons.search, - color: Colors.blue, - ), - ), + appBar: widget.isLoading + ? null + : AppBar( + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only(right: 8), + child: Image.asset('logo.png', width: 24, height: 24), ), - ), - const SizedBox(width: 8), - ElevatedButton( - onPressed: () {}, - style: ElevatedButton.styleFrom( - padding: const EdgeInsets.all(0), - shape: const CircleBorder( - side: BorderSide( - color: Colors.blue, - width: 2, - ), - ), + Align( + alignment: Alignment.centerRight, + child: Text('Powered by GymLink', + style: Theme.of(context).textTheme.titleSmall), ), - child: const Icon( - Icons.shopping_basket, - color: Colors.white, - size: 36, - ), - ), - const SizedBox(width: 8), - ElevatedButton( - onPressed: () {}, - style: ElevatedButton.styleFrom( - padding: const EdgeInsets.all(0), - shape: const CircleBorder( - side: BorderSide( - color: Colors.blue, - width: 2, - ), - ), - ), - child: const Icon( - Icons.history, - color: Colors.white, - size: 36, - ), - ), - ], - ), - ), - body: widget.isLoading - ? const Center(child: CircularProgressIndicator()) - : const Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + ])), + body: widget.isLoading + ? const Center(child: CircularProgressIndicator()) + : Column( + mainAxisAlignment: MainAxisAlignment.start, children: [ - Text( - 'Здесь будут товары', - ), - ], - ), - ), - ); + Row( + children: [ + Expanded( + child: TextField( + decoration: InputDecoration( + hintText: 'Search', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + suffixIcon: InkWell( + onTap: () { + debugPrint('tap on search icon'); + }, + child: const Icon( + Icons.search, + color: Colors.blue, + ), + ), + ), + ), + ), + const SizedBox(width: 8), + ElevatedButton( + onPressed: () { + setState(() { + widget.changeGymLinkScreenTo('basket'); + }); + }, + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.all(0), + backgroundColor: Colors.blue, + shape: const CircleBorder( + side: BorderSide( + color: Colors.blue, + width: 2, + ), + ), + ), + child: const Icon( + Icons.shopping_basket, + color: Colors.white, + size: 24, + ), + ), + const SizedBox(width: 8), + ElevatedButton( + onPressed: () { + setState(() { + widget.changeGymLinkScreenTo('history'); + }); + }, + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.all(0), + backgroundColor: Colors.blue, + shape: const CircleBorder( + side: BorderSide( + color: Colors.blue, + width: 2, + ), + ), + ), + child: const Icon( + Icons.history, + color: Colors.white, + size: 24, + ), + ), + ], + ), + ]) + // : const Center( + // child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Text( + // 'Здесь будут товары', + // ), + // ], + // ), + // ), + ); } } -class TextFieldDemo extends StatelessWidget { - const TextFieldDemo({super.key, required this.title}); - final String title; +class BasketPage extends StatelessWidget { + final void Function(String) changeGymLinkScreenTo; + const BasketPage({super.key, required this.changeGymLinkScreenTo}); @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text(title), - ), - body: const Center( - child: Padding( - padding: EdgeInsets.all(14.0), - child: TextField( - maxLines: null, - decoration: InputDecoration(border: OutlineInputBorder()), + appBar: AppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => changeGymLinkScreenTo('main'), ), + title: const Text('Корзина'), ), - ), - ); + body: const Center( + child: Text('Корзина'), + )); + } +} + +class HistoryPage extends StatelessWidget { + final void Function(String) changeGymLinkScreenTo; + const HistoryPage({super.key, required this.changeGymLinkScreenTo}); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => changeGymLinkScreenTo('main'), + ), + title: const Text('История заказов'), + ), + body: const Center( + child: Text('История заказов'), + )); } } diff --git a/pubspec.yaml b/pubspec.yaml index a1c8b27..a60d351 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -57,6 +57,8 @@ flutter: # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true + assets: + - assets/logo.png # To add assets to your application, add an assets section, like this: # assets: diff --git a/web/css/styles.css b/web/css/styles.css index 14b67ea..5025e30 100644 --- a/web/css/styles.css +++ b/web/css/styles.css @@ -1,7 +1,7 @@ #flutter_target { border: 1px solid #aaa; - width: 320px; - height: 480px; + width: 480px; + height: 600px; border-radius: 0px; transition: all 150ms ease-in; align-self: center;