-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hirosume
committed
Dec 6, 2019
1 parent
46f7f0e
commit 0d8d19f
Showing
22 changed files
with
371 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:flutter_app/blocs/events/RegisterEvent.dart'; | ||
import 'package:flutter_app/blocs/states/RegisterState.dart'; | ||
import 'package:flutter_app/resources/UserRepository.dart'; | ||
|
||
class RegisterBloc extends Bloc<RegisterEvent, RegisterState> { | ||
@override | ||
RegisterState get initialState => OnRegisterState(); | ||
|
||
@override | ||
Stream<RegisterState> mapEventToState(RegisterEvent event) async* { | ||
if (event is OnRegister && event.username.isNotEmpty) { | ||
yield OnRegisteringState(); | ||
await Future.delayed(Duration(seconds: 1)); | ||
try { | ||
await userRepository.register(event.username, event.password); | ||
yield OnRegisterSuccessfulState(); | ||
} catch (e) { | ||
yield OnRegisterFailureState(e.message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter_app/blocs/RegisterBloc.dart'; | ||
import 'package:flutter_app/blocs/events/RegisterEvent.dart'; | ||
import 'package:flutter_app/blocs/states/RegisterState.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
registerCreator(child) { | ||
return BlocProvider( | ||
create: (context) { | ||
return RegisterBloc()..add(OnRegister()); | ||
}, | ||
child: child, | ||
); | ||
} | ||
|
||
registerBuilder(builder) { | ||
return BlocBuilder<RegisterBloc, RegisterState>( | ||
builder: builder, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:equatable/equatable.dart'; | ||
|
||
abstract class RegisterEvent extends Equatable { | ||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class OnRegistering extends RegisterEvent {} | ||
|
||
class OnRegister extends RegisterEvent { | ||
final String username; | ||
final String password; | ||
|
||
OnRegister({this.username = '', this.password = ''}); | ||
|
||
@override | ||
List<Object> get props => [username, password]; | ||
} | ||
|
||
class OnRegisterFailure extends RegisterEvent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:equatable/equatable.dart'; | ||
|
||
abstract class RegisterState extends Equatable { | ||
@override | ||
List<Object> get props => []; | ||
} | ||
|
||
class OnRegisterState extends RegisterState {} | ||
|
||
class OnRegisteringState extends RegisterState {} | ||
|
||
class OnRegisterFailureState extends RegisterState { | ||
final String message; | ||
|
||
OnRegisterFailureState(this.message); | ||
|
||
List<Object> get props => [message]; | ||
} | ||
|
||
class OnRegisterSuccessfulState extends RegisterState {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.