merge dev to devices view

This commit is contained in:
ashrafzarkanisala
2024-08-24 14:21:10 +03:00
32 changed files with 1822 additions and 1095 deletions

View File

@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
Future<void> showCustomDialog({
required BuildContext context,
required String message,
String? title,
String? iconPath,
double? dialogHeight,
double? iconHeight,
double? iconWidth,
VoidCallback? onOkPressed,
bool barrierDismissible = false, required actions,
}) {
return showDialog(
context: context,
barrierDismissible: barrierDismissible,
builder: (BuildContext context) {
final size = MediaQuery.of(context).size;
return AlertDialog(
alignment: Alignment.center,
content: SizedBox(
height: dialogHeight ?? size.height * 0.15,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (iconPath != null)
SvgPicture.asset(
iconPath,
height: iconHeight ?? 35,
width: iconWidth ?? 35,
),
if (title != null)
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
title,
style: Theme.of(context).textTheme.headlineLarge!.copyWith(
fontSize: 20,
fontWeight: FontWeight.w400,
color: Colors.black),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
message,
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(color: Colors.black),
textAlign: TextAlign.center,
),
),
],
),
),
actionsAlignment: MainAxisAlignment.center,
actions: <Widget>[
TextButton(
onPressed: onOkPressed ?? () => Navigator.of(context).pop(),
child: Text(
'OK',
style: Theme.of(context).textTheme.bodySmall!.copyWith(
fontWeight: FontWeight.w400,
color: ColorsManager.blackColor,
fontSize: 16),
),
),
],
);
},
);
}

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
class DynamicTable extends StatefulWidget {
final List<String> headers;
@ -8,20 +10,24 @@ class DynamicTable extends StatefulWidget {
final BoxDecoration? cellDecoration;
final Size size;
final bool withCheckBox;
final bool isEmpty;
final void Function(bool?)? selectAll;
final void Function(int, bool?)? onRowCheckboxChanged;
final List<String>? initialSelectedIds;
const DynamicTable({
Key? key,
super.key,
required this.headers,
required this.data,
required this.size,
required this.isEmpty,
required this.withCheckBox,
this.headerDecoration,
this.cellDecoration,
this.selectAll,
this.onRowCheckboxChanged,
}) : super(key: key);
this.initialSelectedIds,
});
@override
_DynamicTableState createState() => _DynamicTableState();
@ -34,7 +40,11 @@ class _DynamicTableState extends State<DynamicTable> {
@override
void initState() {
super.initState();
_selected = List<bool>.filled(widget.data.length, false);
_selected = List<bool>.generate(widget.data.length, (index) {
return widget.initialSelectedIds != null &&
widget.initialSelectedIds!.contains(widget.data[index][1]);
});
_selectAll = _selected.every((element) => element == true);
}
void _toggleSelectAll(bool? value) {
@ -62,7 +72,7 @@ class _DynamicTableState extends State<DynamicTable> {
return Container(
decoration: widget.cellDecoration,
child: Padding(
padding: const EdgeInsets.all(10.0),
padding: const EdgeInsets.all(2.0),
child: ListView(
scrollDirection: Axis.horizontal,
children: [
@ -82,27 +92,60 @@ class _DynamicTableState extends State<DynamicTable> {
],
),
),
Expanded(
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.data.length,
itemBuilder: (context, index) {
final row = widget.data[index];
return Row(
widget.isEmpty
? Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (widget.withCheckBox) _buildRowCheckbox(index),
...row
.map((cell) =>
_buildTableCell(cell.toString()))
.toList(),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
children: [
SvgPicture.asset(Assets.emptyTable),
const SizedBox(
height: 15,
),
Text(
'No Passwords',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
color: ColorsManager.grayColor),
)
],
),
],
),
],
);
},
),
),
),
),
)
: Expanded(
child: Container(
color: Colors.white,
child: ListView.builder(
shrinkWrap: true,
itemCount: widget.data.length,
itemBuilder: (context, index) {
final row = widget.data[index];
return Row(
children: [
if (widget.withCheckBox)
_buildRowCheckbox(
index, widget.size.height * 0.10),
...row
.map((cell) => _buildTableCell(
cell.toString(),
widget.size.height * 0.10))
.toList(),
],
);
},
),
),
),
],
),
),
@ -113,8 +156,11 @@ class _DynamicTableState extends State<DynamicTable> {
}
Widget _buildSelectAllCheckbox() {
return SizedBox(
width: 50,
return Container(
padding: const EdgeInsets.all(8.0),
decoration: const BoxDecoration(
border: Border.symmetric(
vertical: BorderSide(color: ColorsManager.boxDivider))),
child: Checkbox(
value: _selectAll,
onChanged: _toggleSelectAll,
@ -122,16 +168,26 @@ class _DynamicTableState extends State<DynamicTable> {
);
}
Widget _buildRowCheckbox(int index) {
return SizedBox(
width: 50,
child: Checkbox(
value: _selected[index],
onChanged: (bool? value) {
_toggleRowSelection(index, value);
},
),
);
Widget _buildRowCheckbox(int index, size) {
return Container(
padding: const EdgeInsets.all(8.0),
height: size,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
color: ColorsManager.boxDivider,
width: 1.0,
),
)),
alignment: Alignment.centerLeft,
child: Center(
child: Checkbox(
value: _selected[index],
onChanged: (bool? value) {
_toggleRowSelection(index, value);
},
),
));
}
Widget _buildTableHeaderCell(String title) {
@ -146,17 +202,18 @@ class _DynamicTableState extends State<DynamicTable> {
child: Text(title,
style: const TextStyle(
fontWeight: FontWeight.w400,
color: ColorsManager.lightGreyColor)),
fontSize: 13,
color: Color(0xFF999999))),
),
),
);
}
Widget _buildTableCell(String content) {
Widget _buildTableCell(String content, size) {
return Expanded(
child: Container(
height: 80,
padding: const EdgeInsets.all(15.0),
height: size,
padding: const EdgeInsets.all(5.0),
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(
@ -167,7 +224,8 @@ class _DynamicTableState extends State<DynamicTable> {
alignment: Alignment.centerLeft,
child: Text(
content,
style: const TextStyle(color: Colors.black, fontSize: 12),
style: const TextStyle(
color: Colors.black, fontSize: 10, fontWeight: FontWeight.w400),
),
),
);

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart';
@ -13,6 +14,7 @@ class DateTimeWebWidget extends StatelessWidget {
required this.endTime,
required this.firstString,
required this.secondString,
required this.icon,
});
final Size size;
@ -20,6 +22,7 @@ class DateTimeWebWidget extends StatelessWidget {
final bool isRequired;
final String firstString;
final String secondString;
final String icon;
final Function()? startTime;
final Function()? endTime;
@ -39,35 +42,52 @@ class DateTimeWebWidget extends StatelessWidget {
.bodyMedium!
.copyWith(color: Colors.red),
),
Text(title??''),
Text(title??'' ,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Colors.black,fontSize: 13),),
],
),
SizedBox(height: 8,),
const SizedBox(height: 8,),
Container(
width: size.width * 0.25,
padding: EdgeInsets.all(10),
decoration: containerDecoration,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: startTime,
child: Text(firstString)
),
const Icon(Icons.arrow_right_alt),
InkWell(
onTap:endTime,
child: Text(secondString)),
SvgPicture.asset(
Assets.calendarIcon,
),
],
),
],
)),
height:size.height * 0.055 ,
padding: EdgeInsets.only(top: 10,bottom: 10,right: 30,left: 10),
decoration: containerDecoration,
child: FittedBox(
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: startTime,
child: FittedBox(
child: Text(firstString,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.grayColor,fontSize: 12,fontWeight: FontWeight.w400),),
)
),
SizedBox(width: 30,),
const Icon(Icons.arrow_right_alt),
SizedBox(width: 30,),
InkWell(
onTap:endTime,
child: FittedBox(
child: Text(secondString,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: ColorsManager.grayColor,fontSize: 12,fontWeight: FontWeight.w400),
),
)),
SizedBox(width: 30,),
SvgPicture.asset(
icon,
),
],
),
],
)),
),
],
);
}

View File

@ -0,0 +1,92 @@
import 'package:flutter/material.dart';
class HourPickerDialog extends StatefulWidget {
final TimeOfDay initialTime;
const HourPickerDialog({super.key, required this.initialTime});
@override
_HourPickerDialogState createState() => _HourPickerDialogState();
}
class _HourPickerDialogState extends State<HourPickerDialog> {
late int _selectedHour;
bool _isPm = false;
@override
void initState() {
super.initState();
_selectedHour = widget.initialTime.hour > 12 ? widget.initialTime.hour - 12 : widget.initialTime.hour;
_isPm = widget.initialTime.period == DayPeriod.pm;
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Select Hour'),
content: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
DropdownButton<int>(
value: _selectedHour,
items: List.generate(12, (index) {
int displayHour = index + 1;
return DropdownMenuItem(
value: displayHour,
child: Text(displayHour.toString()),
);
}),
onChanged: (value) {
setState(() {
_selectedHour = value!;
});
},
),
SizedBox(width: 16.0),
DropdownButton<bool>(
value: _isPm,
items: const [
DropdownMenuItem(
value: false,
child: Text('AM'),
),
DropdownMenuItem(
value: true,
child: Text('PM'),
),
],
onChanged: (value) {
setState(() {
_isPm = value!;
});
},
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(null),
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
int hour = _isPm ? _selectedHour + 12 : _selectedHour;
Navigator.of(context).pop(TimeOfDay(hour: hour, minute: 0));
},
child: const Text('OK'),
),
],
);
}
}
Future<TimeOfDay?> showHourPicker({
required BuildContext context,
required TimeOfDay initialTime,
}) {
return showDialog<TimeOfDay>(
context: context,
builder: (context) => HourPickerDialog(initialTime: initialTime),
);
}

View File

@ -66,7 +66,7 @@ class InfoDialog extends StatelessWidget {
onPressed: () {
Navigator.of(context).pop();
},
child: Text('OK'),
child: const Text('OK'),
),
],
);

View File

@ -33,23 +33,23 @@ class CustomWebTextField extends StatelessWidget {
children: [
Text('* ',
style: Theme.of(context)
.textTheme
.bodyMedium!
.textTheme.bodyMedium!
.copyWith(color: Colors.red),
),
Text(textFieldName),
Text(textFieldName, style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Colors.black,fontSize: 13),),
],
),
const SizedBox(width: 10,),
Text(
description??'', // ' The password will be sent to the visitors email address.',
style: Theme.of(context)
.textTheme
.bodySmall!
.copyWith(
fontSize: 9,
fontWeight: FontWeight.w400,
color: ColorsManager.textGray),
Expanded(
child: Text(
description??'',
style: Theme.of(context)
.textTheme.bodySmall!
.copyWith(fontSize: 9,
fontWeight: FontWeight.w400,
color: ColorsManager.textGray),
),
),
],
),
@ -62,21 +62,19 @@ class CustomWebTextField extends StatelessWidget {
color: Colors.grey.withOpacity(0.3),
spreadRadius:2,
blurRadius: 3,
offset: Offset(1, 1), // changes position of shadow
offset: const Offset(1, 1), // changes position of shadow
),
]
),
child: Container(
child: TextFormField(
validator: validator,
controller: controller,
style: const TextStyle(color: Colors.black),
decoration: textBoxDecoration()!
.copyWith(
errorStyle: const TextStyle(height: 0), // Hide the error text space
child: TextFormField(
validator: validator,
controller: controller,
style: const TextStyle(color: Colors.black),
decoration: textBoxDecoration()!
.copyWith(
errorStyle: const TextStyle(height: 0), // Hide the error text space
hintText: 'Please enter'),
),
hintText: 'Please enter'),
),
),
],