visitor password

This commit is contained in:
mohammad
2024-08-13 17:08:18 +03:00
parent 350888c9da
commit 2d0f85bded
15 changed files with 920 additions and 282 deletions

View File

@ -0,0 +1,13 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_event.dart';
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_state.dart';
// Define the BLoC
class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordState> {
VisitorPasswordBloc() : super(VisitorPasswordInitial()) {
on<SelectPasswordType>((event, emit) {
// Handle the event and emit the new state
emit(PasswordTypeSelected(event.type));
});
}
}

View File

@ -0,0 +1,23 @@
import 'package:equatable/equatable.dart';
abstract class VisitorPasswordEvent extends Equatable {
const VisitorPasswordEvent(
);
@override
List<Object> get props => [];
}
class SelectPasswordType extends VisitorPasswordEvent {
final String type;
const SelectPasswordType(this.type);
@override
List<Object> get props => [type];
}

View File

@ -0,0 +1,23 @@
import 'package:equatable/equatable.dart';
abstract class VisitorPasswordState extends Equatable {
const VisitorPasswordState();
@override
List<Object> get props => [];
}
class VisitorPasswordInitial extends VisitorPasswordState {}
class PasswordTypeSelected extends VisitorPasswordState {
final String selectedType;
PasswordTypeSelected(this.selectedType);
@override
List<Object> get props => [selectedType];
}

View File

@ -0,0 +1,290 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart';
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_event.dart';
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_state.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/style.dart';
class VisitorPasswordDialog extends StatelessWidget {
const VisitorPasswordDialog({super.key});
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return BlocProvider(
create: (context) => VisitorPasswordBloc(),
child: BlocBuilder<VisitorPasswordBloc, VisitorPasswordState>(
builder: (context, state) {
return AlertDialog(
title: const Text('Create visitor password'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Text(
'* ',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.red),
),
const Text('User Name'),
],
),
Container(
width: size.width * 0.15,
decoration: containerDecoration,
child: TextFormField(
style: TextStyle(color: Colors.black),
decoration: textBoxDecoration()!
.copyWith(hintText: 'Please enter'),
),
),
],
),
SizedBox(width: size.width * 0.05), // Add spacing between columns
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Text(
'* ',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.red),
),
const Text('Email Address'),
],
),
Container(
width: size.width * 0.15,
decoration: containerDecoration,
child: TextFormField(
style: TextStyle(color: Colors.black),
decoration: textBoxDecoration()!
.copyWith(hintText: 'Please enter'),
),
),
],
),
],
),
SizedBox(height: size.height * 0.02), // Add spacing
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Text(
'* ',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.red),
),
const Text('Access Type'),
],
),
Row(
children: <Widget>[
SizedBox(
width: 200,
child: RadioListTile<String>(
title: Text('Offline Password'),
value: 'Offline Password',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'Offline Password',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
SizedBox(
width: 200,
child: RadioListTile<String>(
title: Text('Online Password'),
value: 'Online Password',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'Offline Password',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
SizedBox(
width: 200,
child: RadioListTile<String>(
title: Text('Dynamic Password'),
value: 'Dynamic Password',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'Offline Password',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
],
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Text(
'* ',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.red),
),
const Text('Usage Frequency'),
],
),
Row(
children: <Widget>[
SizedBox(
width: 200,
child: RadioListTile<String>(
title: const Text('One-Time'),
value: 'One-Time',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'One-Time',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
SizedBox(
width: 200,
child: RadioListTile<String>(
title: Text('Periodic'),
value: 'Periodic',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'Periodic',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
],
)
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
Text(
'* ',
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.red),
),
const Text('Access Period'),
],
),
Row(
children: <Widget>[
SizedBox(
width: 200,
child: RadioListTile<String>(
title: const Text('One-Time'),
value: 'One-Time',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'One-Time',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
SizedBox(
width: 200,
child: RadioListTile<String>(
title: Text('Periodic'),
value: 'Periodic',
groupValue: (state is PasswordTypeSelected)
? state.selectedType
: 'Periodic',
onChanged: (String? value) {
if (value != null) {
context
.read<VisitorPasswordBloc>()
.add(SelectPasswordType(value));
}
},
),
),
],
)
],
),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Approve'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
),
);
}
}