diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 00000000..d077b08b --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,69 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def parse_KV_file(file, separator='=') + file_abs_path = File.expand_path(file) + if !File.exists? file_abs_path + return []; + end + pods_ary = [] + skip_line_start_symbols = ["#", "/"] + File.foreach(file_abs_path) { |line| + next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } + plugin = line.split(pattern=separator) + if plugin.length == 2 + podname = plugin[0].strip() + path = plugin[1].strip() + podpath = File.expand_path("#{path}", file_abs_path) + pods_ary.push({:name => podname, :path => podpath}); + else + puts "Invalid plugin specification: #{line}" + end + } + return pods_ary +end + +target 'Runner' do + # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock + # referring to absolute paths on developers' machines. + system('rm -rf .symlinks') + system('mkdir -p .symlinks/plugins') + + # Flutter Pods + generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') + if generated_xcode_build_settings.empty? + puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." + end + generated_xcode_build_settings.map { |p| + if p[:name] == 'FLUTTER_FRAMEWORK_DIR' + symlink = File.join('.symlinks', 'flutter') + File.symlink(File.dirname(p[:path]), symlink) + pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) + end + } + + # Plugin Pods + plugin_pods = parse_KV_file('../.flutter-plugins') + plugin_pods.map { |p| + symlink = File.join('.symlinks', 'plugins', p[:name]) + File.symlink(p[:path], symlink) + pod p[:name], :path => File.join(symlink, 'ios') + } +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['ENABLE_BITCODE'] = 'NO' + end + end +end diff --git a/lib/constants/index.dart b/lib/constants/index.dart new file mode 100644 index 00000000..ee079656 --- /dev/null +++ b/lib/constants/index.dart @@ -0,0 +1,3 @@ +export 'app_theme.dart'; +export 'dimens.dart'; +export 'strings.dart'; diff --git a/lib/constants/strings.dart b/lib/constants/strings.dart index 2c049d91..f686393d 100644 --- a/lib/constants/strings.dart +++ b/lib/constants/strings.dart @@ -2,11 +2,16 @@ class Strings { Strings._(); //General - static const String appName = "Boilerplate Project"; + static const String appName = 'Boilerplate Project'; //Login - static const String login_et_user_email = "Enter user email"; - static const String login_et_user_password = "Enter password"; - static const String login_btn_forgot_password = "Forgot Password?"; - static const String login_btn_sign_in = "Sign In"; + static const String login_et_user_email = 'Enter user email'; + static const String login_et_user_password = 'Enter password'; + static const String login_btn_forgot_password = 'Forgot Password?'; + static const String login_btn_sign_in = 'Sign In'; + static const String login_validation_error = 'Please fill in all fields'; + + //Posts + static const String posts_title = 'Posts'; + static const String posts_not_found = 'No Posts Found'; } diff --git a/lib/data/index.dart b/lib/data/index.dart new file mode 100644 index 00000000..e06c9336 --- /dev/null +++ b/lib/data/index.dart @@ -0,0 +1 @@ +export 'repository.dart'; diff --git a/lib/data/local/constants/index.dart b/lib/data/local/constants/index.dart new file mode 100644 index 00000000..a8f34230 --- /dev/null +++ b/lib/data/local/constants/index.dart @@ -0,0 +1 @@ +export 'db_constants.dart'; diff --git a/lib/data/local/datasources/post/index.dart b/lib/data/local/datasources/post/index.dart new file mode 100644 index 00000000..340edc22 --- /dev/null +++ b/lib/data/local/datasources/post/index.dart @@ -0,0 +1 @@ +export 'post_datasource.dart'; diff --git a/lib/data/local/index.dart b/lib/data/local/index.dart new file mode 100644 index 00000000..b930557d --- /dev/null +++ b/lib/data/local/index.dart @@ -0,0 +1 @@ +export 'app_database.dart'; diff --git a/lib/data/network/apis/posts/index.dart b/lib/data/network/apis/posts/index.dart new file mode 100644 index 00000000..9d952e97 --- /dev/null +++ b/lib/data/network/apis/posts/index.dart @@ -0,0 +1 @@ +export 'post_api.dart'; diff --git a/lib/data/network/constants/index.dart b/lib/data/network/constants/index.dart new file mode 100644 index 00000000..bf657c52 --- /dev/null +++ b/lib/data/network/constants/index.dart @@ -0,0 +1 @@ +export 'endpoints.dart'; diff --git a/lib/data/network/exceptions/index.dart b/lib/data/network/exceptions/index.dart new file mode 100644 index 00000000..608e3305 --- /dev/null +++ b/lib/data/network/exceptions/index.dart @@ -0,0 +1 @@ +export 'network_exceptions.dart'; diff --git a/lib/data/network/index.dart b/lib/data/network/index.dart new file mode 100644 index 00000000..16ebca69 --- /dev/null +++ b/lib/data/network/index.dart @@ -0,0 +1,2 @@ +export 'dio_client.dart'; +export 'rest_client.dart'; diff --git a/lib/data/sharedpref/constants/index.dart b/lib/data/sharedpref/constants/index.dart new file mode 100644 index 00000000..38d4eaf1 --- /dev/null +++ b/lib/data/sharedpref/constants/index.dart @@ -0,0 +1 @@ +export 'preferences.dart'; diff --git a/lib/models/post/index.dart b/lib/models/post/index.dart new file mode 100644 index 00000000..d6c0a6ab --- /dev/null +++ b/lib/models/post/index.dart @@ -0,0 +1,2 @@ +export 'post.dart'; +export 'post_list.dart'; diff --git a/lib/ui/home/home.dart b/lib/ui/home/home.dart index 232ec470..5707db22 100644 --- a/lib/ui/home/home.dart +++ b/lib/ui/home/home.dart @@ -1,12 +1,14 @@ -import 'package:boilerplate/data/sharedpref/constants/preferences.dart'; -import 'package:boilerplate/routes.dart'; -import 'package:boilerplate/stores/post/post_store.dart'; -import 'package:boilerplate/widgets/progress_indicator_widget.dart'; +import 'package:boilerplate/constants/index.dart'; import 'package:flushbar/flushbar_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import '../../data/sharedpref/constants/preferences.dart'; +import '../../routes.dart'; +import '../../stores/post/post_store.dart'; +import '../../widgets/progress_indicator_widget.dart'; + class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); @@ -34,7 +36,7 @@ class _HomeScreenState extends State { Widget _buildAppBar(BuildContext context) { return AppBar( - title: Text('Posts'), + title: Text(Strings.posts_title), actions: [ IconButton( onPressed: () { @@ -99,7 +101,7 @@ class _HomeScreenState extends State { ); }, ) - : Center(child: Text('No posts found')); + : Center(child: Text(Strings.posts_not_found)); } // General Methods:----------------------------------------------------------- diff --git a/lib/ui/login/login.dart b/lib/ui/login/login.dart index a5b1e6b2..6bd26482 100644 --- a/lib/ui/login/login.dart +++ b/lib/ui/login/login.dart @@ -1,16 +1,17 @@ -import 'package:boilerplate/constants/strings.dart'; -import 'package:boilerplate/data/sharedpref/constants/preferences.dart'; -import 'package:boilerplate/routes.dart'; -import 'package:boilerplate/stores/form/form_store.dart'; -import 'package:boilerplate/widgets/app_icon_widget.dart'; -import 'package:boilerplate/widgets/empty_app_bar_widget.dart'; -import 'package:boilerplate/widgets/progress_indicator_widget.dart'; -import 'package:boilerplate/widgets/rounded_button_widget.dart'; -import 'package:boilerplate/widgets/textfield_widget.dart'; +import 'package:flushbar/flushbar_helper.dart'; import 'package:flutter/material.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; -import 'package:flushbar/flushbar_helper.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../../constants/strings.dart'; +import '../../data/sharedpref/constants/preferences.dart'; +import '../../routes.dart'; +import '../../stores/form/form_store.dart'; +import '../../widgets/app_icon_widget.dart'; +import '../../widgets/empty_app_bar_widget.dart'; +import '../../widgets/progress_indicator_widget.dart'; +import '../../widgets/rounded_button_widget.dart'; +import '../../widgets/textfield_widget.dart'; class LoginScreen extends StatefulWidget { @override @@ -211,7 +212,7 @@ class _LoginScreenState extends State { if (_store.canLogin) { _store.login(); } else { - showErrorMessage(context, 'Please fill in all fields'); + showErrorMessage(context, Strings.login_validation_error); } }, ); diff --git a/lib/ui/splash/splash.dart b/lib/ui/splash/splash.dart index e5b616ec..28bc00c5 100644 --- a/lib/ui/splash/splash.dart +++ b/lib/ui/splash/splash.dart @@ -1,16 +1,19 @@ import 'dart:async'; -import 'package:boilerplate/data/sharedpref/constants/preferences.dart'; -import 'package:boilerplate/routes.dart'; -import 'package:boilerplate/widgets/app_icon_widget.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import '../../data/sharedpref/constants/preferences.dart'; +import '../../routes.dart'; +import '../../widgets/app_icon_widget.dart'; + class SplashScreen extends StatefulWidget { @override State createState() => _SplashScreenState(); } +const bool autoLogin = true; + class _SplashScreenState extends State { @override void initState() { @@ -33,8 +36,8 @@ class _SplashScreenState extends State { navigate() async { SharedPreferences preferences = await SharedPreferences.getInstance(); - if (preferences.getBool(Preferences.is_logged_in) ?? false) { - Navigator.of(context).pushReplacementNamed(Routes.login); + if (autoLogin && preferences.getBool(Preferences.is_logged_in) ?? false) { + Navigator.of(context).pushReplacementNamed(Routes.home); } else { Navigator.of(context).pushReplacementNamed(Routes.login); } diff --git a/lib/utils/dio/index.dart b/lib/utils/dio/index.dart new file mode 100644 index 00000000..361976fa --- /dev/null +++ b/lib/utils/dio/index.dart @@ -0,0 +1 @@ +export 'dio_error_util.dart'; diff --git a/lib/utils/encryption/index.dart b/lib/utils/encryption/index.dart new file mode 100644 index 00000000..cfae3b8d --- /dev/null +++ b/lib/utils/encryption/index.dart @@ -0,0 +1 @@ +export 'xxtea.dart'; diff --git a/lib/widgets/index.dart b/lib/widgets/index.dart new file mode 100644 index 00000000..aa5f9793 --- /dev/null +++ b/lib/widgets/index.dart @@ -0,0 +1,5 @@ +export 'app_icon_widget.dart'; +export 'empty_app_bar_widget.dart'; +export 'progress_indicator_widget.dart'; +export 'rounded_button_widget.dart'; +export 'textfield_widget.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 41ab3b53..f4262805 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,14 +15,15 @@ environment: dependencies: flutter: sdk: flutter - + # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 # The following adds the shared pref as a dependency in your application shared_preferences: ^0.4.3 - + # localstorage: ^2.0.0 + # A composable, Future-based library for making HTTP requests. http: ^0.12.0+1 @@ -65,7 +66,6 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_launcher_icons: "^0.7.0" build_runner: ^1.3.0 flutter_icons: