Skip to content

Commit

Permalink
Merge pull request #82 from mahdiramezanii/develop
Browse files Browse the repository at this point in the history
complated regsiter in project
  • Loading branch information
mahdiramezanii authored May 11, 2024
2 parents 74ed036 + 2db643f commit 5f2ab34
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 151 deletions.
10 changes: 10 additions & 0 deletions lib/bloc/authentication/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,15 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
var response = await iAuth.login(event.username, event.password);
emit(ResponseAuthState(response));
});

on<RegisterUserEvent>((event, emit) async {
emit(LoadingAuthState());
var response = await iAuth.register(
event.username,
event.password,
event.confirmPassword,
);
emit(ResponseAuthState(response));
});
}
}
12 changes: 12 additions & 0 deletions lib/bloc/authentication/auth_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@ class RequestLoginEvent extends AuthEvent {

RequestLoginEvent({required this.username, required this.password});
}

class RegisterUserEvent extends AuthEvent {
String username;
String password;
String confirmPassword;

RegisterUserEvent({
required this.username,
required this.password,
required this.confirmPassword,
});
}
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import 'package:hive_flutter/hive_flutter.dart';
GlobalKey<NavigatorState> globalKey=GlobalKey<NavigatorState>();

void main() async {

WidgetsFlutterBinding();
await Hive.initFlutter();
Hive.registerAdapter(BucketAdapter());
await Hive.openBox<Bucket>("BucketBox");
await initLocator();
runApp(MyApp());

}

class MyApp extends StatelessWidget {
Expand Down
19 changes: 18 additions & 1 deletion lib/screan/login_screan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "package:apple_shop/bloc/authentication/auth_bloc.dart";
import "package:apple_shop/bloc/authentication/auth_event.dart";
import "package:apple_shop/bloc/authentication/auth_state.dart";
import "package:apple_shop/constants/colors.dart";
import "package:apple_shop/screan/bootom_navigation.dart";
import "package:apple_shop/screan/register_screan.dart";

import "package:flutter/cupertino.dart";
Expand Down Expand Up @@ -154,7 +155,23 @@ class LoginScrean extends StatelessWidget {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return RegisterScrean();
return BlocProvider(
create: (context) {
var bloc = AuthBloc();

bloc.stream.forEach((state) {
if (state is ResponseAuthState) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) {
return BottomNavigatonScrean();
}));
}
});

return bloc;
},
child: RegisterScrean(),
);
},
),
);
Expand Down
Loading

0 comments on commit 5f2ab34

Please sign in to comment.