mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
region and access_management ui
This commit is contained in:
@ -1,142 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||
|
||||
class AccessManagementPage extends StatelessWidget {
|
||||
const AccessManagementPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
return WebScaffold(
|
||||
enableMenuSideba: false,
|
||||
appBarTitle: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Access Management',
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
)
|
||||
],
|
||||
),
|
||||
appBarBody: [
|
||||
Text(
|
||||
'Physical Access',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
Text(
|
||||
'App Access',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium!
|
||||
.copyWith(color: Colors.white),
|
||||
)
|
||||
],
|
||||
scaffoldBody: Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width:size.width*0.3,
|
||||
height: size.height*0.05,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('All'),
|
||||
Text('To Be Effective (0)'),
|
||||
Text('Effective (0)'),
|
||||
Text('Expired'),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10,),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width:size.width*0.08,
|
||||
height: size.height*0.05,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: TextFormField()
|
||||
),
|
||||
Container(
|
||||
width:size.width*0.08,
|
||||
height: size.height*0.05,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: TextFormField()
|
||||
),
|
||||
Container(
|
||||
width:size.width*0.08,
|
||||
height: size.height*0.05,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: TextFormField()
|
||||
),
|
||||
Container(
|
||||
width:size.width*0.08,
|
||||
height: size.height*0.05,
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
spreadRadius: 5,
|
||||
blurRadius: 7,
|
||||
offset: Offset(0, 3), // changes position of shadow
|
||||
),
|
||||
],
|
||||
color: ColorsManager.boxColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: TextFormField()
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
26
lib/pages/access_management/bloc/access_bloc.dart
Normal file
26
lib/pages/access_management/bloc/access_bloc.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_event.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
||||
import 'package:syncrow_web/pages/access_management/model/access_manag_model.dart';
|
||||
import 'package:syncrow_web/services/access_mang_api.dart';
|
||||
|
||||
class AccessBloc extends Bloc<AccessEvent, AccessState> {
|
||||
AccessBloc() : super((AccessInitial())) {
|
||||
on<FetchTableData>(_onFetchTableData);
|
||||
}
|
||||
String startTime = 'Start Time';
|
||||
String endTime = 'End Time';
|
||||
|
||||
Future<void> _onFetchTableData(
|
||||
FetchTableData event, Emitter<AccessState> emit) async {
|
||||
try {
|
||||
emit(AccessLoaded());
|
||||
List<AccessManagModel> data = await AccessMangApi().fetchInfo();
|
||||
print('objectwww888888${data[0].accessPeriod}');
|
||||
|
||||
emit(TableLoaded(data));
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
11
lib/pages/access_management/bloc/access_event.dart
Normal file
11
lib/pages/access_management/bloc/access_event.dart
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
abstract class AccessEvent extends Equatable {
|
||||
const AccessEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
class FetchTableData extends AccessEvent {}
|
||||
|
31
lib/pages/access_management/bloc/access_state.dart
Normal file
31
lib/pages/access_management/bloc/access_state.dart
Normal file
@ -0,0 +1,31 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_web/pages/access_management/model/access_manag_model.dart';
|
||||
|
||||
abstract class AccessState extends Equatable {
|
||||
const AccessState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class AccessInitial extends AccessState {}
|
||||
|
||||
class AccessLoaded extends AccessState {}
|
||||
class FailedState extends AccessState {
|
||||
final String message;
|
||||
|
||||
FailedState(this.message);
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
|
||||
class TableLoaded extends AccessState {
|
||||
final List<AccessManagModel> data;
|
||||
|
||||
const TableLoaded(this.data);
|
||||
|
||||
@override
|
||||
List<Object> get props => [data];
|
||||
}
|
||||
|
37
lib/pages/access_management/model/access_manag_model.dart
Normal file
37
lib/pages/access_management/model/access_manag_model.dart
Normal file
@ -0,0 +1,37 @@
|
||||
class AccessManagModel {
|
||||
final String accessUser;
|
||||
final String accessType;
|
||||
final String accessPeriod;
|
||||
final String accessibleDevice;
|
||||
final String authorizationSource;
|
||||
final String authorizer;
|
||||
final String authorizationTime;
|
||||
final String accessStatus;
|
||||
final String actions;
|
||||
|
||||
AccessManagModel({
|
||||
required this.accessUser,
|
||||
required this.accessType,
|
||||
required this.accessPeriod,
|
||||
required this.accessibleDevice,
|
||||
required this.authorizationSource,
|
||||
required this.authorizer,
|
||||
required this.authorizationTime,
|
||||
required this.accessStatus,
|
||||
required this.actions,
|
||||
});
|
||||
|
||||
factory AccessManagModel.fromJson(Map<String, dynamic> json) {
|
||||
return AccessManagModel(
|
||||
accessUser: json['accessUser'],
|
||||
accessType: json['accessType'],
|
||||
accessPeriod: json['accessPeriod'],
|
||||
accessibleDevice: json['accessibleDevice'],
|
||||
authorizationSource: json['authorizationSource'],
|
||||
authorizer: json['authorizer'],
|
||||
authorizationTime: json['authorizationTime'],
|
||||
accessStatus: json['accessStatus'],
|
||||
actions: json['actions'],
|
||||
);
|
||||
}
|
||||
}
|
301
lib/pages/access_management/view/access_management.dart
Normal file
301
lib/pages/access_management/view/access_management.dart
Normal file
@ -0,0 +1,301 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_bloc.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_event.dart';
|
||||
import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
||||
import 'package:syncrow_web/pages/common/default_button.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||
|
||||
class AccessManagementPage extends StatelessWidget {
|
||||
const AccessManagementPage({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return WebScaffold(
|
||||
enableMenuSideba: false,
|
||||
appBarTitle: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Access Management',
|
||||
style: Theme.of(context).textTheme.headlineLarge,
|
||||
)
|
||||
],
|
||||
),
|
||||
appBarBody: [
|
||||
Text(
|
||||
'Physical Access',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineMedium!
|
||||
.copyWith(color: Colors.white),
|
||||
),
|
||||
],
|
||||
scaffoldBody: BlocProvider(
|
||||
create: (BuildContext context) => AccessBloc()..add(FetchTableData() ),
|
||||
child: BlocConsumer<AccessBloc, AccessState>(
|
||||
listener: (context, state) {
|
||||
if (state is FailedState) {
|
||||
// CustomSnackBar.displaySnackBar(
|
||||
// state.errorMessage
|
||||
// );
|
||||
}
|
||||
}, builder: (context, state) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(30),
|
||||
height: size.height,
|
||||
width: size.width,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: size.width * 0.3,
|
||||
height: size.height * 0.05,
|
||||
decoration: containerDecoration,
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text('All'),
|
||||
Text('To Be Effective (0)'),
|
||||
Text('Effective (0)'),
|
||||
Text('Expired'),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Wrap(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text('User Name'),
|
||||
Container(
|
||||
width: size.width*0.15,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(hintText: 'Please enter'),
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Email Address'),
|
||||
Container(
|
||||
width: size.width*0.15,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(hintText: 'Please enter'),
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Access Time'),
|
||||
Container(
|
||||
width: size.width*0.18,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: containerDecoration,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(child: Text(BlocProvider.of<AccessBloc>(context).startTime)),
|
||||
const Icon(Icons.arrow_right_alt),
|
||||
InkWell(child: Text(BlocProvider.of<AccessBloc>(context).endTime)),
|
||||
SvgPicture.asset(
|
||||
Assets.calendarIcon,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Authorization Source'),
|
||||
Container(
|
||||
width: size.width*0.18,
|
||||
decoration: containerDecoration,
|
||||
child: TextFormField(
|
||||
decoration: textBoxDecoration(),
|
||||
)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 15,),
|
||||
SizedBox(
|
||||
width: size.width*0.06,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(''),
|
||||
Container(
|
||||
decoration: containerDecoration,
|
||||
|
||||
child: DefaultButton(child: Text('Search'),borderRadius: 9)),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10,),
|
||||
SizedBox(
|
||||
width: size.width*0.06,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(''),
|
||||
Container(
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
backgroundColor: ColorsManager.whiteColors,borderRadius: 9,
|
||||
child: Text('Reset'
|
||||
,style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.black),)
|
||||
,),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Wrap(children: [
|
||||
Container(
|
||||
width: size.width*0.15,
|
||||
decoration: containerDecoration,
|
||||
child: const DefaultButton(
|
||||
borderRadius: 8,
|
||||
child: Text('+ Create Visitor Password ')),
|
||||
),
|
||||
const SizedBox(width: 10,),
|
||||
Container(
|
||||
width: size.width*0.12,
|
||||
decoration: containerDecoration,
|
||||
child: DefaultButton(
|
||||
borderRadius: 8,
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
child: Text('Admin Password'
|
||||
,style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.black),)
|
||||
))
|
||||
],),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child:state is TableLoaded?
|
||||
Container(
|
||||
decoration: containerDecoration,
|
||||
width: size.width,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
Container(
|
||||
width: size.width,
|
||||
height:size.height ,
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Container(
|
||||
color: ColorsManager.boxColor,
|
||||
child: Row(
|
||||
children: [
|
||||
_buildTableHeaderCell('Access User'),
|
||||
_buildTableHeaderCell('Access Type'),
|
||||
_buildTableHeaderCell('Access Period'),
|
||||
_buildTableHeaderCell('Accessible Device'),
|
||||
_buildTableHeaderCell('Authorization Source'),
|
||||
_buildTableHeaderCell('Authorizer'),
|
||||
_buildTableHeaderCell('Authorization Time'),
|
||||
_buildTableHeaderCell('Access Status'),
|
||||
_buildTableHeaderCell('Actions'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: size.width,
|
||||
color: ColorsManager.whiteColors,
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
Column(
|
||||
children: state.data.map((item) {
|
||||
return Row(
|
||||
children: [
|
||||
_buildTableCell(item.accessUser),
|
||||
_buildTableCell(item.accessType),
|
||||
_buildTableCell(item.accessPeriod),
|
||||
_buildTableCell(item.accessibleDevice),
|
||||
_buildTableCell(item.authorizationSource),
|
||||
_buildTableCell(item.authorizer),
|
||||
_buildTableCell(item.authorizationTime),
|
||||
_buildTableCell(item.accessStatus),
|
||||
_buildTableCell(item.actions),
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
):const Center(child: CircularProgressIndicator())
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
})));
|
||||
}
|
||||
}
|
||||
Widget _buildTableHeaderCell(String title) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border.symmetric(vertical: BorderSide(color: ColorsManager.boxDivider))
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(title, style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTableCell(String content) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border.symmetric(horizontal: BorderSide(color: ColorsManager.boxDivider))
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(content,style: TextStyle(color: Colors.black,fontSize: 12),),
|
||||
),
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user