update
This commit is contained in:
parent
a76d3a0f35
commit
e3dc94a768
33 changed files with 368 additions and 184 deletions
14
lib/blocs/guest/functions/bloc_getgueststatus.dart
Normal file
14
lib/blocs/guest/functions/bloc_getgueststatus.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/guest_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/guest_event.dart';
|
||||
|
||||
Future<bool> blocGetGuestStatus(BuildContext context) async {
|
||||
try {
|
||||
final guestBloc = context.read<GuestBloc>();
|
||||
guestBloc.add(GuestGetStatus());
|
||||
return guestBloc.state.value;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
14
lib/blocs/guest/functions/bloc_setguestoff.dart
Normal file
14
lib/blocs/guest/functions/bloc_setguestoff.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/guest_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/guest_event.dart';
|
||||
|
||||
Future<bool> blocSetGuestOff(BuildContext context) async {
|
||||
try {
|
||||
final guestBloc = context.read<GuestBloc>();
|
||||
guestBloc.add(GuestSetOff());
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
14
lib/blocs/guest/functions/bloc_setgueston.dart
Normal file
14
lib/blocs/guest/functions/bloc_setgueston.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/guest_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/guest/guest_event.dart';
|
||||
|
||||
Future<bool> blocSetGuestOn(BuildContext context) async {
|
||||
try {
|
||||
final guestBloc = context.read<GuestBloc>();
|
||||
guestBloc.add(GuestSetOn());
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
17
lib/blocs/guest/guest_bloc.dart
Normal file
17
lib/blocs/guest/guest_bloc.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'guest_event.dart';
|
||||
import 'guest_state.dart';
|
||||
|
||||
class GuestBloc extends Bloc<GuestEvent, GuestState> {
|
||||
GuestBloc() : super(GuestState(false)) {
|
||||
on<GuestSetOn>((event, emit) {
|
||||
emit(GuestState(true));
|
||||
});
|
||||
on<GuestSetOff>((event, emit) {
|
||||
emit(GuestState(false));
|
||||
});
|
||||
on<GuestGetStatus>((event, emit) {
|
||||
emit(state);
|
||||
});
|
||||
}
|
||||
}
|
||||
7
lib/blocs/guest/guest_event.dart
Normal file
7
lib/blocs/guest/guest_event.dart
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
abstract class GuestEvent {}
|
||||
|
||||
class GuestSetOn extends GuestEvent {}
|
||||
|
||||
class GuestSetOff extends GuestEvent {}
|
||||
|
||||
class GuestGetStatus extends GuestEvent {}
|
||||
5
lib/blocs/guest/guest_state.dart
Normal file
5
lib/blocs/guest/guest_state.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class GuestState {
|
||||
final bool value;
|
||||
|
||||
GuestState(this.value);
|
||||
}
|
||||
14
lib/blocs/user/functions/bloc_getuser.dart
Normal file
14
lib/blocs/user/functions/bloc_getuser.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/user/user_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/user/user_event.dart';
|
||||
|
||||
Future<String> blocGetUser(BuildContext context) async {
|
||||
try {
|
||||
final userBloc = context.read<UserBloc>();
|
||||
userBloc.add(UserGetValue());
|
||||
return userBloc.state.value;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
14
lib/blocs/user/functions/bloc_setuser.dart
Normal file
14
lib/blocs/user/functions/bloc_setuser.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/user/user_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/user/user_event.dart';
|
||||
|
||||
Future<bool> blocSetUser(BuildContext context, String value) async {
|
||||
try {
|
||||
final userBloc = context.read<UserBloc>();
|
||||
userBloc.add(UserSetValue(value));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
14
lib/blocs/user/user_bloc.dart
Normal file
14
lib/blocs/user/user_bloc.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:pharmacy_mobile/blocs/user/user_event.dart';
|
||||
import 'package:pharmacy_mobile/blocs/user/user_state.dart';
|
||||
|
||||
class UserBloc extends Bloc<UserEvent, UserState> {
|
||||
UserBloc() : super(UserState('')) {
|
||||
on<UserSetValue>((event, emit) {
|
||||
emit(UserState(event.value));
|
||||
});
|
||||
on<UserGetValue>((event, emit) {
|
||||
emit(state);
|
||||
});
|
||||
}
|
||||
}
|
||||
8
lib/blocs/user/user_event.dart
Normal file
8
lib/blocs/user/user_event.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
abstract class UserEvent {}
|
||||
|
||||
class UserSetValue extends UserEvent {
|
||||
final String value;
|
||||
UserSetValue(this.value);
|
||||
}
|
||||
|
||||
class UserGetValue extends UserEvent {}
|
||||
5
lib/blocs/user/user_state.dart
Normal file
5
lib/blocs/user/user_state.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class UserState {
|
||||
final String value;
|
||||
|
||||
UserState(this.value);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue