Skip to content

Commit

Permalink
Merge pull request SimpleBoilerplates#13 from SimpleBoilerplates/rive…
Browse files Browse the repository at this point in the history
…rpod

Sign Up and refactor
  • Loading branch information
Sadmansamee authored Oct 24, 2021
2 parents 3683398 + 31bd3e3 commit b9f7b03
Show file tree
Hide file tree
Showing 25 changed files with 523 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.0.2/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/","dependencies":[]},{"name":"path_provider","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.5/","dependencies":[]},{"name":"shared_preferences","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.8/","dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.0.2/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/","dependencies":[]},{"name":"path_provider","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.5/","dependencies":[]},{"name":"shared_preferences","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.8/","dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.1/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.2/","dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.1.0/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/","dependencies":[]},{"name":"path_provider_linux","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.0/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.0.2/","dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus_windows","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.0/","dependencies":[]},{"name":"path_provider_windows","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.3/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.0.2/","dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus_web","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.1.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2021-10-24 12:42:27.200867","version":"2.5.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.0.2/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/","dependencies":[]},{"name":"path_provider","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.5/","dependencies":[]},{"name":"shared_preferences","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.8/","dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.0.2/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/","dependencies":[]},{"name":"path_provider","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.5/","dependencies":[]},{"name":"shared_preferences","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-2.0.8/","dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.1/","dependencies":[]},{"name":"path_provider_macos","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-2.0.2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-2.0.2/","dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.1.0/","dependencies":[]},{"name":"flutter_secure_storage","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-4.2.1/","dependencies":[]},{"name":"path_provider_linux","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-2.1.0/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_linux-2.0.2/","dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus_windows","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.0/","dependencies":[]},{"name":"path_provider_windows","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.3/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_windows-2.0.2/","dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus_web","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.1.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/sadmansamee/development/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-2.0.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2021-10-24 19:10:38.033948","version":"2.5.3"}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ app.*.map.json
!.idea/codeStyles/
!.idea/dictionaries/
!.idea/runConfigurations/
.flutter-plugins-dependencies
6 changes: 3 additions & 3 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/sadmansamee/development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/sadmansamee/Documents/Personal/flutter_boilerplate"
export "FLUTTER_APPLICATION_PATH=/Users/sadmansamee/Documents/Personal/Flutter/flutter_boilerplate"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=/Users/sadmansamee/Documents/Personal/flutter_boilerplate/lib/main_staging.dart"
export "FLUTTER_TARGET=/Users/sadmansamee/Documents/Personal/Flutter/flutter_boilerplate/lib/main_staging.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=/Users/sadmansamee/Documents/Personal/flutter_boilerplate/.dart_tool/package_config.json"
export "PACKAGE_CONFIG=/Users/sadmansamee/Documents/Personal/Flutter/flutter_boilerplate/.dart_tool/package_config.json"
12 changes: 6 additions & 6 deletions lib/app/provider/app_start_provider.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:flutter_boilerplate/app/state/app_start_state.dart';
import 'package:flutter_boilerplate/feature/auth/model/login_state.dart';
import 'package:flutter_boilerplate/feature/auth/provider/login_provider.dart';
import 'package:flutter_boilerplate/feature/auth/model/auth_state.dart';
import 'package:flutter_boilerplate/feature/auth/provider/auth_provider.dart';
import 'package:flutter_boilerplate/feature/home/provider/home_provider.dart';
import 'package:flutter_boilerplate/feature/home/state/home_state.dart';
import 'package:flutter_boilerplate/shared/repository/token_repository.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

final appStartProvider =
StateNotifierProvider<AppStartNotifier, AppStartState>((ref) {
final loginState = ref.watch(loginProvider);
final loginState = ref.watch(authProvider);
final homeState = ref.watch(homeProvider);

late AppStartState appStartState;
Expand All @@ -21,19 +21,19 @@ final appStartProvider =

class AppStartNotifier extends StateNotifier<AppStartState> {
late TokenRepository _tokenRepository;
final LoginState loginState;
final AuthState authState;
final HomeState homeState;

AppStartNotifier(AppStartState appStartState, ProviderRefBase ref,
this.loginState, this.homeState)
this.authState, this.homeState)
: super(appStartState) {
_tokenRepository = ref.read(tokenRepositoryProvider);
//state = const AppStartState.authenticated();
_init();
}

void _init() async {
loginState.maybeWhen(
authState.maybeWhen(
loggedIn: () {
state = const AppStartState.authenticated();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'package:flutter/material.dart';
import 'package:flutter_boilerplate/app/provider/app_start_provider.dart';
import 'package:flutter_boilerplate/feature/auth/widget/sign_in_widget.dart';
import 'package:flutter_boilerplate/feature/home/widget/home_widget.dart';
import 'package:flutter_boilerplate/feature/auth/widget/sign_in_page.dart';
import 'package:flutter_boilerplate/feature/home/widget/home_page.dart';
import 'package:flutter_boilerplate/shared/widget/connection_unavailable_widget.dart';
import 'package:flutter_boilerplate/shared/widget/loading_widget.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class AppStartWidget extends ConsumerWidget {
const AppStartWidget({Key? key}) : super(key: key);
class AppStartPage extends ConsumerWidget {
const AppStartPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context, WidgetRef ref) {
final state = ref.watch(appStartProvider);

return state.maybeWhen(
initial: () => const LoadingWidget(),
authenticated: () => HomeWidget(),
unauthenticated: () => SignInWidget(),
authenticated: () => HomePage(),
unauthenticated: () => SignInPage(),
internetUnAvailable: () => const ConnectionUnavailableWidget(),
orElse: () => const LoadingWidget(),
);
Expand Down
12 changes: 12 additions & 0 deletions lib/feature/auth/model/auth_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter_boilerplate/shared/http/app_exception.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'auth_state.freezed.dart';

@freezed
class AuthState with _$AuthState {
const factory AuthState.initial() = _Initial;
const factory AuthState.loading() = _Loading;
const factory AuthState.loggedIn() = _LoggedIn;
const factory AuthState.error(AppException error) = _Error;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target

part of 'login_state.dart';
part of 'auth_state.dart';

// **************************************************************************
// FreezedGenerator
Expand All @@ -14,8 +14,8 @@ final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

/// @nodoc
class _$LoginStateTearOff {
const _$LoginStateTearOff();
class _$AuthStateTearOff {
const _$AuthStateTearOff();

_Initial initial() {
return const _Initial();
Expand All @@ -37,10 +37,10 @@ class _$LoginStateTearOff {
}

/// @nodoc
const $LoginState = _$LoginStateTearOff();
const $AuthState = _$AuthStateTearOff();

/// @nodoc
mixin _$LoginState {
mixin _$AuthState {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() initial,
Expand Down Expand Up @@ -94,19 +94,18 @@ mixin _$LoginState {
}

/// @nodoc
abstract class $LoginStateCopyWith<$Res> {
factory $LoginStateCopyWith(
LoginState value, $Res Function(LoginState) then) =
_$LoginStateCopyWithImpl<$Res>;
abstract class $AuthStateCopyWith<$Res> {
factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) =
_$AuthStateCopyWithImpl<$Res>;
}

/// @nodoc
class _$LoginStateCopyWithImpl<$Res> implements $LoginStateCopyWith<$Res> {
_$LoginStateCopyWithImpl(this._value, this._then);
class _$AuthStateCopyWithImpl<$Res> implements $AuthStateCopyWith<$Res> {
_$AuthStateCopyWithImpl(this._value, this._then);

final LoginState _value;
final AuthState _value;
// ignore: unused_field
final $Res Function(LoginState) _then;
final $Res Function(AuthState) _then;
}

/// @nodoc
Expand All @@ -116,7 +115,7 @@ abstract class _$InitialCopyWith<$Res> {
}

/// @nodoc
class __$InitialCopyWithImpl<$Res> extends _$LoginStateCopyWithImpl<$Res>
class __$InitialCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
implements _$InitialCopyWith<$Res> {
__$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
: super(_value, (v) => _then(v as _Initial));
Expand All @@ -132,7 +131,7 @@ class _$_Initial implements _Initial {

@override
String toString() {
return 'LoginState.initial()';
return 'AuthState.initial()';
}

@override
Expand Down Expand Up @@ -219,7 +218,7 @@ class _$_Initial implements _Initial {
}
}

abstract class _Initial implements LoginState {
abstract class _Initial implements AuthState {
const factory _Initial() = _$_Initial;
}

Expand All @@ -230,7 +229,7 @@ abstract class _$LoadingCopyWith<$Res> {
}

/// @nodoc
class __$LoadingCopyWithImpl<$Res> extends _$LoginStateCopyWithImpl<$Res>
class __$LoadingCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
implements _$LoadingCopyWith<$Res> {
__$LoadingCopyWithImpl(_Loading _value, $Res Function(_Loading) _then)
: super(_value, (v) => _then(v as _Loading));
Expand All @@ -246,7 +245,7 @@ class _$_Loading implements _Loading {

@override
String toString() {
return 'LoginState.loading()';
return 'AuthState.loading()';
}

@override
Expand Down Expand Up @@ -333,7 +332,7 @@ class _$_Loading implements _Loading {
}
}

abstract class _Loading implements LoginState {
abstract class _Loading implements AuthState {
const factory _Loading() = _$_Loading;
}

Expand All @@ -344,7 +343,7 @@ abstract class _$LoggedInCopyWith<$Res> {
}

/// @nodoc
class __$LoggedInCopyWithImpl<$Res> extends _$LoginStateCopyWithImpl<$Res>
class __$LoggedInCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
implements _$LoggedInCopyWith<$Res> {
__$LoggedInCopyWithImpl(_LoggedIn _value, $Res Function(_LoggedIn) _then)
: super(_value, (v) => _then(v as _LoggedIn));
Expand All @@ -360,7 +359,7 @@ class _$_LoggedIn implements _LoggedIn {

@override
String toString() {
return 'LoginState.loggedIn()';
return 'AuthState.loggedIn()';
}

@override
Expand Down Expand Up @@ -447,7 +446,7 @@ class _$_LoggedIn implements _LoggedIn {
}
}

abstract class _LoggedIn implements LoginState {
abstract class _LoggedIn implements AuthState {
const factory _LoggedIn() = _$_LoggedIn;
}

Expand All @@ -461,7 +460,7 @@ abstract class _$ErrorCopyWith<$Res> {
}

/// @nodoc
class __$ErrorCopyWithImpl<$Res> extends _$LoginStateCopyWithImpl<$Res>
class __$ErrorCopyWithImpl<$Res> extends _$AuthStateCopyWithImpl<$Res>
implements _$ErrorCopyWith<$Res> {
__$ErrorCopyWithImpl(_Error _value, $Res Function(_Error) _then)
: super(_value, (v) => _then(v as _Error));
Expand Down Expand Up @@ -499,7 +498,7 @@ class _$_Error implements _Error {

@override
String toString() {
return 'LoginState.error(error: $error)';
return 'AuthState.error(error: $error)';
}

@override
Expand Down Expand Up @@ -593,7 +592,7 @@ class _$_Error implements _Error {
}
}

abstract class _Error implements LoginState {
abstract class _Error implements AuthState {
const factory _Error(AppException error) = _$_Error;

AppException get error;
Expand Down
12 changes: 0 additions & 12 deletions lib/feature/auth/model/login_state.dart

This file was deleted.

Loading

0 comments on commit b9f7b03

Please sign in to comment.