mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fixes bugs and re add checkboxes theme
This commit is contained in:
@ -1 +0,0 @@
|
|||||||
|
|
@ -15,7 +15,8 @@ Future<void> main() async {
|
|||||||
initialSetup();
|
initialSetup();
|
||||||
String checkToken = await AuthBloc.getTokenAndValidate();
|
String checkToken = await AuthBloc.getTokenAndValidate();
|
||||||
GoRouter router = GoRouter(
|
GoRouter router = GoRouter(
|
||||||
initialLocation: checkToken == 'Success' ? RoutesConst.home : RoutesConst.auth,
|
initialLocation:
|
||||||
|
checkToken == 'Success' ? RoutesConst.home : RoutesConst.auth,
|
||||||
routes: AppRoutes.getRoutes(),
|
routes: AppRoutes.getRoutes(),
|
||||||
);
|
);
|
||||||
runApp(MyApp(
|
runApp(MyApp(
|
||||||
@ -54,7 +55,9 @@ class MyApp extends StatelessWidget {
|
|||||||
fontFamily: 'Aftika',
|
fontFamily: 'Aftika',
|
||||||
textTheme: const TextTheme(
|
textTheme: const TextTheme(
|
||||||
bodySmall: TextStyle(
|
bodySmall: TextStyle(
|
||||||
fontSize: 13, color: ColorsManager.whiteColors, fontWeight: FontWeight.bold),
|
fontSize: 13,
|
||||||
|
color: ColorsManager.whiteColors,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
bodyMedium: TextStyle(color: Colors.black87, fontSize: 14),
|
bodyMedium: TextStyle(color: Colors.black87, fontSize: 14),
|
||||||
bodyLarge: TextStyle(fontSize: 16, color: Colors.white),
|
bodyLarge: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
headlineSmall: TextStyle(color: Colors.black87, fontSize: 18),
|
headlineSmall: TextStyle(color: Colors.black87, fontSize: 18),
|
||||||
@ -65,7 +68,40 @@ class MyApp extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
colorScheme: ColorScheme.fromSeed(
|
||||||
|
seedColor: ColorsManager.blueColor,
|
||||||
|
primary: ColorsManager.blueColor,
|
||||||
|
onSurface: Colors.grey.shade400,
|
||||||
),
|
),
|
||||||
|
switchTheme: SwitchThemeData(
|
||||||
|
thumbColor: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return ColorsManager.blueColor;
|
||||||
|
}
|
||||||
|
return ColorsManager.whiteColors;
|
||||||
|
}),
|
||||||
|
trackColor: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return ColorsManager.blueColor.withOpacity(0.5);
|
||||||
|
}
|
||||||
|
return ColorsManager.whiteColors;
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
checkboxTheme: CheckboxThemeData(
|
||||||
|
fillColor: WidgetStateProperty.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.selected)) {
|
||||||
|
return ColorsManager.blueColor;
|
||||||
|
}
|
||||||
|
return Colors.grey.shade200;
|
||||||
|
}),
|
||||||
|
checkColor: WidgetStateProperty.all(Colors.white),
|
||||||
|
side: const BorderSide(color: ColorsManager.whiteColors),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
routeInformationProvider: router.routeInformationProvider,
|
routeInformationProvider: router.routeInformationProvider,
|
||||||
routerDelegate: router.routerDelegate,
|
routerDelegate: router.routerDelegate,
|
||||||
routeInformationParser: router.routeInformationParser,
|
routeInformationParser: router.routeInformationParser,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class StatefulTextField extends StatefulWidget {
|
class StatefulTextField extends StatefulWidget {
|
||||||
const StatefulTextField({
|
const StatefulTextField({
|
||||||
|
@ -18,6 +18,7 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
@ -31,7 +32,7 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: isLarge
|
crossAxisCount: isLarge || isExtraLarge
|
||||||
? 3
|
? 3
|
||||||
: isMedium
|
: isMedium
|
||||||
? 2
|
? 2
|
||||||
|
@ -36,7 +36,7 @@ class DeviceManagementPage extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
|
|
||||||
return DeviceManagementBody(devices: devices);
|
return DeviceManagementBody(devices: devices);
|
||||||
} else {
|
} else {
|
||||||
return const Center(child: Text('No Devices Found'));
|
return const Center(child: Text('Error fetching Devices'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||||
import 'package:syncrow_web/pages/common/custom_table.dart';
|
import 'package:syncrow_web/pages/common/custom_table.dart';
|
||||||
import 'package:syncrow_web/pages/common/filter/filter_widget.dart';
|
import 'package:syncrow_web/pages/common/filter/filter_widget.dart';
|
||||||
|
@ -10,6 +10,7 @@ class CeilingSensorModel {
|
|||||||
String bodyMovement;
|
String bodyMovement;
|
||||||
String noBodyTime;
|
String noBodyTime;
|
||||||
int maxDistance;
|
int maxDistance;
|
||||||
|
String spaceType;
|
||||||
|
|
||||||
CeilingSensorModel({
|
CeilingSensorModel({
|
||||||
required this.presenceState,
|
required this.presenceState,
|
||||||
@ -20,6 +21,7 @@ class CeilingSensorModel {
|
|||||||
required this.bodyMovement,
|
required this.bodyMovement,
|
||||||
required this.noBodyTime,
|
required this.noBodyTime,
|
||||||
required this.maxDistance,
|
required this.maxDistance,
|
||||||
|
required this.spaceType,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory CeilingSensorModel.fromJson(List<Status> jsonList) {
|
factory CeilingSensorModel.fromJson(List<Status> jsonList) {
|
||||||
@ -31,6 +33,7 @@ class CeilingSensorModel {
|
|||||||
String _bodyMovement = 'none';
|
String _bodyMovement = 'none';
|
||||||
String _noBodyTime = 'none';
|
String _noBodyTime = 'none';
|
||||||
int _maxDis = 0;
|
int _maxDis = 0;
|
||||||
|
String _spaceType = 'none';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var status in jsonList) {
|
for (var status in jsonList) {
|
||||||
@ -38,17 +41,26 @@ class CeilingSensorModel {
|
|||||||
case 'presence_state':
|
case 'presence_state':
|
||||||
_presenceState = status.value ?? 'none';
|
_presenceState = status.value ?? 'none';
|
||||||
break;
|
break;
|
||||||
|
case 'scene':
|
||||||
|
_spaceType = status.value ?? 'none';
|
||||||
|
break;
|
||||||
case 'sensitivity':
|
case 'sensitivity':
|
||||||
_sensitivity = status.value is int ? status.value : int.tryParse(status.value ?? '1') ?? 1;
|
_sensitivity = status.value is int
|
||||||
|
? status.value
|
||||||
|
: int.tryParse(status.value ?? '1') ?? 1;
|
||||||
break;
|
break;
|
||||||
case 'checking_result':
|
case 'checking_result':
|
||||||
_checkingResult = status.value ?? '';
|
_checkingResult = status.value ?? '';
|
||||||
break;
|
break;
|
||||||
case 'presence_range':
|
case 'presence_range':
|
||||||
_presenceRange = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
_presenceRange = status.value is int
|
||||||
|
? status.value
|
||||||
|
: int.tryParse(status.value ?? '0') ?? 0;
|
||||||
break;
|
break;
|
||||||
case 'sports_para':
|
case 'sports_para':
|
||||||
_sportsPara = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
_sportsPara = status.value is int
|
||||||
|
? status.value
|
||||||
|
: int.tryParse(status.value ?? '0') ?? 0;
|
||||||
break;
|
break;
|
||||||
case 'body_movement':
|
case 'body_movement':
|
||||||
_bodyMovement = status.value ?? '';
|
_bodyMovement = status.value ?? '';
|
||||||
@ -57,7 +69,9 @@ class CeilingSensorModel {
|
|||||||
_noBodyTime = status.value ?? 'none';
|
_noBodyTime = status.value ?? 'none';
|
||||||
break;
|
break;
|
||||||
case 'moving_max_dis':
|
case 'moving_max_dis':
|
||||||
_maxDis = status.value is int ? status.value : int.tryParse(status.value ?? '0') ?? 0;
|
_maxDis = status.value is int
|
||||||
|
? status.value
|
||||||
|
: int.tryParse(status.value ?? '0') ?? 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,6 +88,7 @@ class CeilingSensorModel {
|
|||||||
bodyMovement: _bodyMovement,
|
bodyMovement: _bodyMovement,
|
||||||
noBodyTime: _noBodyTime,
|
noBodyTime: _noBodyTime,
|
||||||
maxDistance: _maxDis,
|
maxDistance: _maxDis,
|
||||||
|
spaceType: _spaceType,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
@ -35,8 +36,8 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
state is CeilingReportsLoadingState) {
|
state is CeilingReportsLoadingState) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is CeilingUpdateState) {
|
} else if (state is CeilingUpdateState) {
|
||||||
return _buildGridView(
|
return _buildGridView(context, state.ceilingSensorModel,
|
||||||
context, state.ceilingSensorModel, isLarge, isMedium);
|
isExtraLarge, isLarge, isMedium);
|
||||||
} else if (state is CeilingReportsState) {
|
} else if (state is CeilingReportsState) {
|
||||||
return ReportsTable(
|
return ReportsTable(
|
||||||
report: state.deviceReport,
|
report: state.deviceReport,
|
||||||
@ -58,7 +59,8 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
);
|
);
|
||||||
} else if (state is CeilingReportsFailedState) {
|
} else if (state is CeilingReportsFailedState) {
|
||||||
final model = context.read<CeilingSensorBloc>().deviceStatus;
|
final model = context.read<CeilingSensorBloc>().deviceStatus;
|
||||||
return _buildGridView(context, model, isLarge, isMedium);
|
return _buildGridView(
|
||||||
|
context, model, isExtraLarge, isLarge, isMedium);
|
||||||
}
|
}
|
||||||
return const Center(child: Text('Error fetching status'));
|
return const Center(child: Text('Error fetching status'));
|
||||||
},
|
},
|
||||||
@ -67,13 +69,13 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildGridView(BuildContext context, CeilingSensorModel model,
|
Widget _buildGridView(BuildContext context, CeilingSensorModel model,
|
||||||
bool isLarge, bool isMedium) {
|
bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||||
return GridView(
|
return GridView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: isLarge
|
crossAxisCount: isLarge || isExtraLarge
|
||||||
? 3
|
? 3
|
||||||
: isMedium
|
: isMedium
|
||||||
? 2
|
? 2
|
||||||
@ -96,8 +98,8 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
postfix: 'm',
|
postfix: 'm',
|
||||||
description: 'Detection Range',
|
description: 'Detection Range',
|
||||||
),
|
),
|
||||||
const PresenceSpaceType(
|
PresenceSpaceType(
|
||||||
listOfIcons: [
|
listOfIcons: const [
|
||||||
Assets.office,
|
Assets.office,
|
||||||
Assets.parlour,
|
Assets.parlour,
|
||||||
Assets.dyi,
|
Assets.dyi,
|
||||||
@ -105,6 +107,7 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
Assets.bedroom,
|
Assets.bedroom,
|
||||||
],
|
],
|
||||||
description: 'Space Type',
|
description: 'Space Type',
|
||||||
|
value: model.spaceType,
|
||||||
),
|
),
|
||||||
PresenceUpdateData(
|
PresenceUpdateData(
|
||||||
value: model.sensitivity.toDouble(),
|
value: model.sensitivity.toDouble(),
|
||||||
@ -138,7 +141,7 @@ class CeilingSensorControls extends StatelessWidget
|
|||||||
PresenceNoBodyTime(
|
PresenceNoBodyTime(
|
||||||
value: model.noBodyTime,
|
value: model.noBodyTime,
|
||||||
title: 'Nobody Time:',
|
title: 'Nobody Time:',
|
||||||
// description: 'hr',
|
description: '',
|
||||||
action: (String value) => context.read<CeilingSensorBloc>().add(
|
action: (String value) => context.read<CeilingSensorBloc>().add(
|
||||||
CeilingChangeValueEvent(
|
CeilingChangeValueEvent(
|
||||||
code: 'nobody_time',
|
code: 'nobody_time',
|
||||||
|
@ -34,9 +34,9 @@ class DoorLockView extends StatelessWidget {
|
|||||||
} else if (state is UpdateState) {
|
} else if (state is UpdateState) {
|
||||||
return _buildStatusControls(context, state.smartDoorModel);
|
return _buildStatusControls(context, state.smartDoorModel);
|
||||||
} else if (state is DoorLockControlError) {
|
} else if (state is DoorLockControlError) {
|
||||||
return Center(child: Text(state.message));
|
return const SizedBox();
|
||||||
} else {
|
} else {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: Text('Error fetching status'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -14,6 +14,7 @@ class GateWayControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ class GateWayControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: isLarge
|
crossAxisCount: isLarge || isExtraLarge
|
||||||
? 3
|
? 3
|
||||||
: isMedium
|
: isMedium
|
||||||
? 2
|
? 2
|
||||||
@ -45,7 +46,7 @@ class GateWayControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return const Center(child: Text('Error fetching devices'));
|
return const Center(child: Text('Error fetching status'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -24,7 +24,7 @@ class LivingRoomDeviceControl extends StatelessWidget
|
|||||||
return _buildStatusControls(context, state.status);
|
return _buildStatusControls(context, state.status);
|
||||||
} else if (state is LivingRoomDeviceManagementError ||
|
} else if (state is LivingRoomDeviceManagementError ||
|
||||||
state is LivingRoomControlError) {
|
state is LivingRoomControlError) {
|
||||||
return Center(child: Text(state.toString()));
|
return const Center(child: Text('Error fetching status'));
|
||||||
} else {
|
} else {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
@ -35,6 +35,7 @@ class LivingRoomDeviceControl extends StatelessWidget
|
|||||||
|
|
||||||
Widget _buildStatusControls(
|
Widget _buildStatusControls(
|
||||||
BuildContext context, LivingRoomStatusModel status) {
|
BuildContext context, LivingRoomStatusModel status) {
|
||||||
|
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
||||||
return GridView(
|
return GridView(
|
||||||
@ -42,7 +43,7 @@ class LivingRoomDeviceControl extends StatelessWidget
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: isLarge
|
crossAxisCount: isLarge || isExtraLarge
|
||||||
? 3
|
? 3
|
||||||
: isMedium
|
: isMedium
|
||||||
? 2
|
? 2
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/helper/route_controls_based_code.dart';
|
||||||
|
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/core/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
@ -9,10 +10,12 @@ class PresenceSpaceType extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.listOfIcons,
|
required this.listOfIcons,
|
||||||
required this.description,
|
required this.description,
|
||||||
|
required this.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> listOfIcons;
|
final List<String> listOfIcons;
|
||||||
final String description;
|
final String description;
|
||||||
|
final String value;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -36,10 +39,20 @@ class PresenceSpaceType extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
...listOfIcons.map((icon) => SvgPicture.asset(
|
...listOfIcons.map((icon) => Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(100),
|
||||||
|
border: Border.all(
|
||||||
|
color: icon.contains(value)
|
||||||
|
? ColorsManager.blueColor
|
||||||
|
: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SvgPicture.asset(
|
||||||
icon,
|
icon,
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -23,6 +23,8 @@ class PresenceNoBodyTime extends StatefulWidget {
|
|||||||
|
|
||||||
class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
||||||
late String _currentValue;
|
late String _currentValue;
|
||||||
|
late String _numericValue;
|
||||||
|
late String _unit;
|
||||||
|
|
||||||
final List<String> nobodyTimeRange = [
|
final List<String> nobodyTimeRange = [
|
||||||
'none',
|
'none',
|
||||||
@ -40,29 +42,45 @@ class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_currentValue = widget.value;
|
_currentValue = widget.value;
|
||||||
|
_numericValue = _extractNumericValue(_currentValue);
|
||||||
|
_unit = _extractUnit(_currentValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _extractNumericValue(String value) {
|
||||||
|
if (value == 'none') return '0';
|
||||||
|
return value.replaceAll(RegExp(r'[a-zA-Z]'), '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
String _extractUnit(String value) {
|
||||||
|
if (value == 'none') return '';
|
||||||
|
if (value.endsWith('s')) return 's';
|
||||||
|
if (value.endsWith('min')) return 'min';
|
||||||
|
if (value.endsWith('hour')) return 'hr';
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onValueChanged(String newValue) {
|
void _onValueChanged(String newValue) {
|
||||||
|
setState(() {
|
||||||
|
_currentValue = newValue;
|
||||||
|
_numericValue = _extractNumericValue(newValue);
|
||||||
|
_unit = _extractUnit(newValue);
|
||||||
|
});
|
||||||
widget.action(newValue);
|
widget.action(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _incrementValue() {
|
void _incrementValue() {
|
||||||
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
||||||
if (currentIndex < nobodyTimeRange.length - 1) {
|
if (currentIndex < nobodyTimeRange.length - 1) {
|
||||||
setState(() {
|
String newValue = nobodyTimeRange[currentIndex + 1];
|
||||||
_currentValue = nobodyTimeRange[currentIndex + 1];
|
_onValueChanged(newValue);
|
||||||
});
|
|
||||||
_onValueChanged(_currentValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _decrementValue() {
|
void _decrementValue() {
|
||||||
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
int currentIndex = nobodyTimeRange.indexOf(_currentValue);
|
||||||
if (currentIndex > 0) {
|
if (currentIndex > 0) {
|
||||||
setState(() {
|
String newValue = nobodyTimeRange[currentIndex - 1];
|
||||||
_currentValue = nobodyTimeRange[currentIndex - 1];
|
_onValueChanged(newValue);
|
||||||
});
|
|
||||||
_onValueChanged(_currentValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +99,12 @@ class _PresenceUpdateDataState extends State<PresenceNoBodyTime> {
|
|||||||
fontSize: 10),
|
fontSize: 10),
|
||||||
),
|
),
|
||||||
IncrementDecrementWidget(
|
IncrementDecrementWidget(
|
||||||
value: _currentValue,
|
value: _numericValue,
|
||||||
description: widget.description ?? '',
|
description: _unit,
|
||||||
descriptionColor: ColorsManager.blackColor,
|
descriptionColor: ColorsManager.blackColor,
|
||||||
onIncrement: _incrementValue,
|
onIncrement: _incrementValue,
|
||||||
onDecrement: _decrementValue),
|
onDecrement: _decrementValue,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user