From 8f023856dba15039f2b22d35dcc569af2fc9c191 Mon Sep 17 00:00:00 2001 From: vb Date: Thu, 6 Aug 2020 02:32:44 +0300 Subject: [PATCH] login buttons added and page view atom molecul page etc. added --- asset/lang/{en_US.json => en-US.json} | 0 ios/Podfile.lock | 34 +++++++++ ios/Runner.xcodeproj/project.pbxproj | 71 +++++++++++++++++++ .../contents.xcworkspacedata | 3 + lib/core/base/view/base_widget.dart | 1 + lib/core/components/avatar/circle_avatar.dart | 0 lib/core/components/button/icon_button.dart | 19 +++++ lib/core/components/button/normal_button.dart | 18 +++++ .../components/button/title_text_button.dart | 19 +++++ lib/core/components/column/form_column.dart | 22 ++++++ .../list-view/indicator_list_view.dart | 45 ++++++++++++ lib/core/extension/context_extension.dart | 11 +++ lib/main.dart | 5 +- .../_widgets/button/face_book_button.dart | 31 ++++++++ lib/view/_widgets/button/login_button.dart | 18 +++++ .../_widgets/listview/on_board_indicator.dart | 19 +++++ .../authenticate/login/view/login_view.dart | 29 +++++--- .../onboard/model/on_board_model.dart | 5 ++ .../view-model/on_board_view_model.dart | 27 +++++++ .../view-model/on_board_view_model.g.dart | 48 +++++++++++++ .../onboard/view/on_board_view.dart | 62 ++++++++++++++++ .../test/viewmodel/test_view_model.dart | 10 ++- 22 files changed, 481 insertions(+), 16 deletions(-) rename asset/lang/{en_US.json => en-US.json} (100%) create mode 100644 ios/Podfile.lock create mode 100644 lib/core/components/avatar/circle_avatar.dart create mode 100644 lib/core/components/button/icon_button.dart create mode 100644 lib/core/components/button/normal_button.dart create mode 100644 lib/core/components/button/title_text_button.dart create mode 100644 lib/core/components/column/form_column.dart create mode 100644 lib/core/components/list-view/indicator_list_view.dart create mode 100644 lib/view/_widgets/button/face_book_button.dart create mode 100644 lib/view/_widgets/button/login_button.dart create mode 100644 lib/view/_widgets/listview/on_board_indicator.dart create mode 100644 lib/view/authenticate/onboard/model/on_board_model.dart create mode 100644 lib/view/authenticate/onboard/view-model/on_board_view_model.dart create mode 100644 lib/view/authenticate/onboard/view-model/on_board_view_model.g.dart create mode 100644 lib/view/authenticate/onboard/view/on_board_view.dart diff --git a/asset/lang/en_US.json b/asset/lang/en-US.json similarity index 100% rename from asset/lang/en_US.json rename to asset/lang/en-US.json diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..3f85d49 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - Flutter (1.0.0) + - shared_preferences (0.0.1): + - Flutter + - shared_preferences_macos (0.0.1): + - Flutter + - shared_preferences_web (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) + - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" + shared_preferences_macos: + :path: ".symlinks/plugins/shared_preferences_macos/ios" + shared_preferences_web: + :path: ".symlinks/plugins/shared_preferences_web/ios" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d + shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 + shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 + +PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a + +COCOAPODS: 1.9.3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 5986548..0c936cc 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 98D03AC8BD0EB475973728E4 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03715CDAED8CFDE3AEA71199 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -29,12 +30,15 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 03715CDAED8CFDE3AEA71199 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 171537F7682C238A232F6BCC /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7FA0B0E8A3A23E79DE9F2470 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -42,6 +46,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BA2F0552EA5A958FC7EF6EBA /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,12 +54,32 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 98D03AC8BD0EB475973728E4 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 601926BF140CCFC1D114815A /* Pods */ = { + isa = PBXGroup; + children = ( + 7FA0B0E8A3A23E79DE9F2470 /* Pods-Runner.debug.xcconfig */, + BA2F0552EA5A958FC7EF6EBA /* Pods-Runner.release.xcconfig */, + 171537F7682C238A232F6BCC /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 6153A895178271A935C4DE89 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 03715CDAED8CFDE3AEA71199 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +97,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 601926BF140CCFC1D114815A /* Pods */, + 6153A895178271A935C4DE89 /* Frameworks */, ); sourceTree = ""; }; @@ -105,12 +132,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + CCCA04282C9E58583AA58C1F /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 8FF5D6EEFEAF7A9CAB609868 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -183,6 +212,26 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 8FF5D6EEFEAF7A9CAB609868 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${PODS_ROOT}/../Flutter/Flutter.framework", + "${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -197,6 +246,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + CCCA04282C9E58583AA58C1F /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/lib/core/base/view/base_widget.dart b/lib/core/base/view/base_widget.dart index 40bce62..72e127f 100644 --- a/lib/core/base/view/base_widget.dart +++ b/lib/core/base/view/base_widget.dart @@ -18,6 +18,7 @@ class _BaseViewState extends State> { T model; @override void initState() { + model = widget.viewModel; widget.onModelReady(model); super.initState(); } diff --git a/lib/core/components/avatar/circle_avatar.dart b/lib/core/components/avatar/circle_avatar.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/core/components/button/icon_button.dart b/lib/core/components/button/icon_button.dart new file mode 100644 index 0000000..dd9b1db --- /dev/null +++ b/lib/core/components/button/icon_button.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +import 'normal_button.dart'; + +class IconNormalButton extends StatelessWidget { + final VoidCallback onPressed; + final IconData icon; + + const IconNormalButton({Key key, this.onPressed, @required this.icon}) : super(key: key); + @override + Widget build(BuildContext context) { + return NormalButton( + onPressed: this.onPressed, + child: Center( + child: Icon(icon), + ), + ); + } +} diff --git a/lib/core/components/button/normal_button.dart b/lib/core/components/button/normal_button.dart new file mode 100644 index 0000000..b8dadfe --- /dev/null +++ b/lib/core/components/button/normal_button.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +class NormalButton extends StatelessWidget { + final Widget child; + + final VoidCallback onPressed; + + const NormalButton({Key key, this.child, this.onPressed}) : super(key: key); + @override + Widget build(BuildContext context) { + return RaisedButton( + padding: EdgeInsets.all(15), + elevation: 10, + onPressed: this.onPressed, + child: child, + ); + } +} diff --git a/lib/core/components/button/title_text_button.dart b/lib/core/components/button/title_text_button.dart new file mode 100644 index 0000000..f77c76a --- /dev/null +++ b/lib/core/components/button/title_text_button.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +import 'normal_button.dart'; + +class TitleTextButton extends StatelessWidget { + final VoidCallback onPressed; + final String text; + + const TitleTextButton({Key key, this.onPressed, @required this.text}) : super(key: key); + @override + Widget build(BuildContext context) { + return NormalButton( + onPressed: this.onPressed, + child: Center( + child: Text(text), + ), + ); + } +} diff --git a/lib/core/components/column/form_column.dart b/lib/core/components/column/form_column.dart new file mode 100644 index 0000000..55df16d --- /dev/null +++ b/lib/core/components/column/form_column.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; + +class FormColumn extends StatelessWidget { + final List children; + + const FormColumn({Key key, this.children}) : super(key: key); + @override + Widget build(BuildContext context) { + return Row( + children: [ + Spacer(flex: 1), + Expanded( + flex: 8, + child: Column( + children: this.children, + ), + ), + Spacer(flex: 1), + ], + ); + } +} diff --git a/lib/core/components/list-view/indicator_list_view.dart b/lib/core/components/list-view/indicator_list_view.dart new file mode 100644 index 0000000..583f8ac --- /dev/null +++ b/lib/core/components/list-view/indicator_list_view.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; + +import '../../extension/context_extension.dart'; + +class IndactorListView extends StatelessWidget { + final int itemCount; + + final int currentIndex; + + final Widget Function(int index) onListItem; + + const IndactorListView({Key key, this.itemCount, this.onListItem, this.currentIndex}) : super(key: key); + @override + Widget build(BuildContext context) { + return ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: itemCount, + shrinkWrap: true, + itemBuilder: (context, index) => buildPadding(context, index), + ); + } + + Padding buildPadding(BuildContext context, int index) { + return Padding( + padding: context.paddingLow, + child: buildCircleAvatar(index, context), + ); + } + + CircleAvatar buildCircleAvatar(int index, BuildContext context) { + return CircleAvatar( + backgroundColor: isCurrentIndex(index) ? Colors.black12 : Colors.blue, + radius: isCurrentIndex(index) ? context.width * 0.03 : context.width * 0.015, + child: AnimatedOpacity( + opacity: opacityValue(index), + duration: context.normalDuration, + child: onListItem(index), + ), + ); + } + + double opacityValue(int index) => isCurrentIndex(index) ? 1 : 0; + + bool isCurrentIndex(int index) => currentIndex == index; +} diff --git a/lib/core/extension/context_extension.dart b/lib/core/extension/context_extension.dart index b2d5ac5..1c1282f 100644 --- a/lib/core/extension/context_extension.dart +++ b/lib/core/extension/context_extension.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; extension ContextExtension on BuildContext { @@ -26,3 +28,12 @@ extension PaddingExtension on BuildContext { EdgeInsets get paddingMedium => EdgeInsets.all(mediumValue); EdgeInsets get paddingHigh => EdgeInsets.all(highValue); } + +extension PageExtension on BuildContext { + Color get randomColor => Colors.primaries[Random().nextInt(17)]; +} + +extension DurationExtension on BuildContext { + Duration get lowDuration => Duration(milliseconds: 500); + Duration get normalDuration => Duration(seconds: 1); +} diff --git a/lib/main.dart b/lib/main.dart index 2d83614..4a84359 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; +import 'package:fluttermvvmtemplate/view/authenticate/login/view/login_view.dart'; +import 'package:fluttermvvmtemplate/view/authenticate/onboard/view/on_board_view.dart'; import 'package:provider/provider.dart'; import 'core/constants/app/app_constants.dart'; @@ -12,6 +14,7 @@ import 'core/init/notifier/theme_notifer.dart'; import 'view/authenticate/test/view/test_view.dart'; void main() { + WidgetsFlutterBinding.ensureInitialized(); LocaleManager.prefrencesInit(); runApp(MultiProvider( providers: [...ApplicationProvider.instance.dependItems], @@ -27,7 +30,7 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( theme: Provider.of(context, listen: false).currentTheme, - home: TestsView(), + home: OnBoardView(), onGenerateRoute: NavigationRoute.instance.generateRoute, navigatorKey: NavigationService.instance.navigatorKey, ); diff --git a/lib/view/_widgets/button/face_book_button.dart b/lib/view/_widgets/button/face_book_button.dart new file mode 100644 index 0000000..2bb33ea --- /dev/null +++ b/lib/view/_widgets/button/face_book_button.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:fluttermvvmtemplate/core/components/button/title_text_button.dart'; + +class FaceBookButton extends StatelessWidget { + final Function(FaceBookModel data, {String errorMessage}) onComplete; + + const FaceBookButton({Key key, this.onComplete}) : super(key: key); + + @override + Widget build(BuildContext context) { + return TitleTextButton( + text: "Facebbok login", + onPressed: () { + final isLengthSixCharacter = "asdasdasd".length == 6; + + if (isLengthSixCharacter) { + this.onComplete(FaceBookModel("asdasd", "ASdasd")); + } else { + this.onComplete(null, errorMessage: "Facebook user not found"); + } + }, + ); + } +} + +class FaceBookModel { + final String token; + final String mail; + + FaceBookModel(this.token, this.mail); +} diff --git a/lib/view/_widgets/button/login_button.dart b/lib/view/_widgets/button/login_button.dart new file mode 100644 index 0000000..1c25271 --- /dev/null +++ b/lib/view/_widgets/button/login_button.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:fluttermvvmtemplate/core/components/button/icon_button.dart'; + +class MVVMLoginButton extends StatelessWidget { + final Function(String data) onComplete; + + const MVVMLoginButton({Key key, this.onComplete}) : super(key: key); + @override + Widget build(BuildContext context) { + return IconNormalButton( + icon: Icons.access_alarm, + onPressed: () { + onComplete("OKEY"); + // BUSINESS CALL + }, + ); + } +} diff --git a/lib/view/_widgets/listview/on_board_indicator.dart b/lib/view/_widgets/listview/on_board_indicator.dart new file mode 100644 index 0000000..c24aeb1 --- /dev/null +++ b/lib/view/_widgets/listview/on_board_indicator.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:fluttermvvmtemplate/core/components/list-view/indicator_list_view.dart'; + +class OnBoardIndcator extends StatelessWidget { + final int itemCount; + final int currentIndex; + + const OnBoardIndcator({Key key, this.itemCount, this.currentIndex}) : super(key: key); + @override + Widget build(BuildContext context) { + return IndactorListView( + currentIndex: currentIndex, + itemCount: itemCount, + onListItem: (index) { + return FlutterLogo(); + }, + ); + } +} diff --git a/lib/view/authenticate/login/view/login_view.dart b/lib/view/authenticate/login/view/login_view.dart index d3bf6f8..d7bea5f 100644 --- a/lib/view/authenticate/login/view/login_view.dart +++ b/lib/view/authenticate/login/view/login_view.dart @@ -1,33 +1,44 @@ import 'package:flutter/material.dart'; +import 'package:fluttermvvmtemplate/core/components/button/icon_button.dart'; +import 'package:fluttermvvmtemplate/view/_widgets/button/face_book_button.dart'; +import 'package:fluttermvvmtemplate/view/_widgets/button/login_button.dart'; import '../../../../core/base/view/base_widget.dart'; import '../../../../core/extension/context_extension.dart'; import '../viewmodel/login_view_model.dart'; class LoginView extends StatelessWidget { + GlobalKey scaffoldKey = GlobalKey(); + + LoginViewModel viewModel; @override Widget build(BuildContext context) { return BaseView( viewModel: LoginViewModel(), onModelReady: (model) { model.setContext(context); + model.init(); + viewModel = model; }, onPageBuilder: (BuildContext context, LoginViewModel value) => buildScaffold(context), ); } Scaffold buildScaffold(BuildContext context) => Scaffold( - body: ListView( + key: scaffoldKey, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - Container( - padding: context.paddingLow, - height: context.height * .4, - color: Theme.of(context).buttonTheme.colorScheme.onPrimary, - child: buildText(context), + TextField( + decoration: InputDecoration(enabledBorder: OutlineInputBorder()), ), - Padding( - padding: EdgeInsets.symmetric(horizontal: context.lowValue), - child: Placeholder(), + FaceBookButton( + onComplete: (data, {errorMessage}) { + if (data != null) { + } else { + scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(errorMessage))); + } + }, ) ], ), diff --git a/lib/view/authenticate/onboard/model/on_board_model.dart b/lib/view/authenticate/onboard/model/on_board_model.dart new file mode 100644 index 0000000..d81e899 --- /dev/null +++ b/lib/view/authenticate/onboard/model/on_board_model.dart @@ -0,0 +1,5 @@ +class OnBoardModel { + final String text; + + OnBoardModel(this.text); +} diff --git a/lib/view/authenticate/onboard/view-model/on_board_view_model.dart b/lib/view/authenticate/onboard/view-model/on_board_view_model.dart new file mode 100644 index 0000000..371fcb3 --- /dev/null +++ b/lib/view/authenticate/onboard/view-model/on_board_view_model.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:fluttermvvmtemplate/core/base/model/base_view_model.dart'; +import 'package:fluttermvvmtemplate/view/authenticate/onboard/model/on_board_model.dart'; +import 'package:mobx/mobx.dart'; +part 'on_board_view_model.g.dart'; + +class OnBoardViewModel = _OnBoardViewModelBase with _$OnBoardViewModel; + +abstract class _OnBoardViewModelBase with Store, BaseViewModel { + void setContext(BuildContext context) { + this.context = context; + } + + void init() { + onBoarModel = List.generate(5, (index) => OnBoardModel(index.toString())); + } + + List onBoarModel; + + @observable + int currentPageIndex = 0; + + @action + void onPageChanged(int value) { + currentPageIndex = value; + } +} diff --git a/lib/view/authenticate/onboard/view-model/on_board_view_model.g.dart b/lib/view/authenticate/onboard/view-model/on_board_view_model.g.dart new file mode 100644 index 0000000..27be928 --- /dev/null +++ b/lib/view/authenticate/onboard/view-model/on_board_view_model.g.dart @@ -0,0 +1,48 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'on_board_view_model.dart'; + +// ************************************************************************** +// StoreGenerator +// ************************************************************************** + +// ignore_for_file: non_constant_identifier_names, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic + +mixin _$OnBoardViewModel on _OnBoardViewModelBase, Store { + final _$currentPageIndexAtom = + Atom(name: '_OnBoardViewModelBase.currentPageIndex'); + + @override + int get currentPageIndex { + _$currentPageIndexAtom.reportRead(); + return super.currentPageIndex; + } + + @override + set currentPageIndex(int value) { + _$currentPageIndexAtom.reportWrite(value, super.currentPageIndex, () { + super.currentPageIndex = value; + }); + } + + final _$_OnBoardViewModelBaseActionController = + ActionController(name: '_OnBoardViewModelBase'); + + @override + void onPageChanged(int value) { + final _$actionInfo = _$_OnBoardViewModelBaseActionController.startAction( + name: '_OnBoardViewModelBase.onPageChanged'); + try { + return super.onPageChanged(value); + } finally { + _$_OnBoardViewModelBaseActionController.endAction(_$actionInfo); + } + } + + @override + String toString() { + return ''' +currentPageIndex: ${currentPageIndex} + '''; + } +} diff --git a/lib/view/authenticate/onboard/view/on_board_view.dart b/lib/view/authenticate/onboard/view/on_board_view.dart new file mode 100644 index 0000000..1f3ff77 --- /dev/null +++ b/lib/view/authenticate/onboard/view/on_board_view.dart @@ -0,0 +1,62 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:fluttermvvmtemplate/core/base/view/base_widget.dart'; +import 'package:fluttermvvmtemplate/core/components/column/form_column.dart'; +import 'package:fluttermvvmtemplate/core/extension/context_extension.dart'; +import 'package:fluttermvvmtemplate/view/_widgets/listview/on_board_indicator.dart'; +import 'package:fluttermvvmtemplate/view/authenticate/onboard/view-model/on_board_view_model.dart'; + +class OnBoardView extends StatefulWidget { + @override + _OnBoardViewState createState() => _OnBoardViewState(); +} + +class _OnBoardViewState extends State { + OnBoardViewModel viewModel; + @override + Widget build(BuildContext context) { + return BaseView( + viewModel: OnBoardViewModel(), + onModelReady: (model) { + model.setContext(context); + model.init(); + viewModel = model; + }, + onPageBuilder: (BuildContext context, OnBoardViewModel value) => Scaffold( + body: buildColumnBody(), + ), + ); + } + + Column buildColumnBody() { + return Column( + children: [Expanded(flex: 9, child: buildPageView()), Expanded(child: buildObserverIndcator())], + ); + } + + PageView buildPageView() { + return PageView.builder( + onPageChanged: (value) { + viewModel.onPageChanged(value); + }, + itemCount: viewModel.onBoarModel.length, + itemBuilder: (context, index) => Container( + color: context.randomColor, + child: FormColumn( + children: [Placeholder(), Text(viewModel.onBoarModel[index].text)], + ), + ), + ); + } + + Observer buildObserverIndcator() { + return Observer(builder: (_) { + return OnBoardIndcator( + itemCount: viewModel.onBoarModel.length, + currentIndex: viewModel.currentPageIndex, + ); + }); + } +} diff --git a/lib/view/authenticate/test/viewmodel/test_view_model.dart b/lib/view/authenticate/test/viewmodel/test_view_model.dart index 7cec398..248ef68 100644 --- a/lib/view/authenticate/test/viewmodel/test_view_model.dart +++ b/lib/view/authenticate/test/viewmodel/test_view_model.dart @@ -15,7 +15,9 @@ part 'test_view_model.g.dart'; class TestViewModel = _TestViewModelBase with _$TestViewModel; abstract class _TestViewModelBase with Store, BaseViewModel { - void setContext(BuildContext context) => this.context = context; + void setContext(BuildContext context) { + this.context = context; + } void init() {} @@ -40,14 +42,10 @@ abstract class _TestViewModelBase with Store, BaseViewModel { @action Future getSampleRequest() async { isLoading = true; - // final list = await NetworkManager.instance.dioGet("x", TestModel()); final response = await coreDio.fetch, TestModel>("x", type: HttpTypes.GET, parseModel: TestModel()); if (response.data is List) { - //print true - } else { - // response.error; - } + } else {} isLoading = false; } }