refactor(ui): Update some UI and fix some bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.8.20'
|
ext.kotlin_version = '1.8.22'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -1,11 +1,25 @@
|
|||||||
include ':app'
|
pluginManagement {
|
||||||
|
def flutterSdkPath = {
|
||||||
|
def properties = new Properties()
|
||||||
|
file("local.properties").withInputStream { properties.load(it) }
|
||||||
|
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||||
|
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||||
|
return flutterSdkPath
|
||||||
|
}()
|
||||||
|
|
||||||
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||||
def properties = new Properties()
|
|
||||||
|
|
||||||
assert localPropertiesFile.exists()
|
repositories {
|
||||||
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
plugins {
|
||||||
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||||
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
id "com.android.application" version "8.2.1" apply false
|
||||||
|
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
|
||||||
|
}
|
||||||
|
|
||||||
|
include ":app"
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:sfm_app/product/constant/app/app_constants.dart';
|
|
||||||
|
|
||||||
import '../feature/devices/device_model.dart';
|
import '../feature/devices/device_model.dart';
|
||||||
import '../product/base/bloc/base_bloc.dart';
|
import '../product/base/bloc/base_bloc.dart';
|
||||||
|
import '../product/constant/app/app_constants.dart';
|
||||||
import '../product/services/api_services.dart';
|
import '../product/services/api_services.dart';
|
||||||
|
|
||||||
import '../product/utils/device_utils.dart';
|
import '../product/utils/device_utils.dart';
|
||||||
@@ -26,11 +25,57 @@ class DevicesManagerBloc extends BlocBase {
|
|||||||
Stream<Map<String, List<Device>>> get streamDeviceByState =>
|
Stream<Map<String, List<Device>>> get streamDeviceByState =>
|
||||||
deviceByState.stream;
|
deviceByState.stream;
|
||||||
|
|
||||||
|
final tagStates = StreamController<List<int>>.broadcast();
|
||||||
|
StreamSink<List<int>> get sinkTagStates => tagStates.sink;
|
||||||
|
Stream<List<int>> get streamTagStates => tagStates.stream;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {}
|
void dispose() {}
|
||||||
|
|
||||||
void getDevice() async {
|
// void getDevice() async {
|
||||||
String body = await apiServices.getOwnerDevices();
|
// String body = await apiServices.getOwnerDevices();
|
||||||
|
// Map<String, List<Device>> deviceByState = {
|
||||||
|
// ApplicationConstants.OFFLINE_STATE: [],
|
||||||
|
// ApplicationConstants.NORMAL_STATE: [],
|
||||||
|
// ApplicationConstants.WARNING_STATE: [],
|
||||||
|
// ApplicationConstants.INPROGRESS_STATE: [],
|
||||||
|
// ApplicationConstants.ERROR_STATE: [],
|
||||||
|
// };
|
||||||
|
// if (body.isNotEmpty) {
|
||||||
|
// final data = jsonDecode(body);
|
||||||
|
// List<dynamic> items = data['items'];
|
||||||
|
// List<Device> originalDevices = Device.fromJsonDynamicList(items);
|
||||||
|
// List<Device> devices =
|
||||||
|
// DeviceUtils.instance.sortDeviceByState(originalDevices);
|
||||||
|
// for (var device in devices) {
|
||||||
|
// String stateKey;
|
||||||
|
// switch (device.state) {
|
||||||
|
// case -1:
|
||||||
|
// stateKey = ApplicationConstants.OFFLINE_STATE;
|
||||||
|
// break;
|
||||||
|
// case 0:
|
||||||
|
// stateKey = ApplicationConstants.NORMAL_STATE;
|
||||||
|
// break;
|
||||||
|
// case 1:
|
||||||
|
// stateKey = ApplicationConstants.WARNING_STATE;
|
||||||
|
// break;
|
||||||
|
// case 2:
|
||||||
|
// stateKey = ApplicationConstants.INPROGRESS_STATE;
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// stateKey = ApplicationConstants.ERROR_STATE;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// deviceByState[stateKey]!.add(device);
|
||||||
|
// }
|
||||||
|
// sinkAllDevices.add(devices);
|
||||||
|
// sinkDeviceByState.add(deviceByState);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
void getDeviceByState(int state) async {
|
||||||
|
sinkTagStates.add([state]);
|
||||||
|
|
||||||
Map<String, List<Device>> deviceByState = {
|
Map<String, List<Device>> deviceByState = {
|
||||||
ApplicationConstants.OFFLINE_STATE: [],
|
ApplicationConstants.OFFLINE_STATE: [],
|
||||||
ApplicationConstants.NORMAL_STATE: [],
|
ApplicationConstants.NORMAL_STATE: [],
|
||||||
@@ -39,35 +84,49 @@ class DevicesManagerBloc extends BlocBase {
|
|||||||
ApplicationConstants.ERROR_STATE: [],
|
ApplicationConstants.ERROR_STATE: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
List<Device> devices = [];
|
||||||
|
String body;
|
||||||
|
|
||||||
|
if (state != -2) {
|
||||||
|
body =
|
||||||
|
await apiServices.getOwnerDevieByState({"state": state.toString()});
|
||||||
|
} else {
|
||||||
|
body = await apiServices.getOwnerDevices();
|
||||||
|
}
|
||||||
|
|
||||||
if (body.isNotEmpty) {
|
if (body.isNotEmpty) {
|
||||||
final data = jsonDecode(body);
|
final data = jsonDecode(body);
|
||||||
List<dynamic> items = data['items'];
|
List<dynamic> items = data['items'];
|
||||||
List<Device> originalDevices = Device.fromJsonDynamicList(items);
|
List<Device> originalDevices = Device.fromJsonDynamicList(items);
|
||||||
List<Device> devices =
|
|
||||||
DeviceUtils.instance.sortDeviceByState(originalDevices);
|
devices = (state != -2)
|
||||||
for (var device in devices) {
|
? DeviceUtils.instance.sortDeviceAZByName(originalDevices)
|
||||||
String stateKey;
|
: DeviceUtils.instance.sortDeviceByState(originalDevices);
|
||||||
switch (device.state) {
|
|
||||||
case -1:
|
if (state == -2) {
|
||||||
stateKey = ApplicationConstants.OFFLINE_STATE;
|
for (var device in originalDevices) {
|
||||||
break;
|
String stateKey = _getStateKey(device.state!);
|
||||||
case 0:
|
deviceByState[stateKey]!.add(device);
|
||||||
stateKey = ApplicationConstants.NORMAL_STATE;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
stateKey = ApplicationConstants.WARNING_STATE;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
stateKey = ApplicationConstants.INPROGRESS_STATE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
stateKey = ApplicationConstants.ERROR_STATE;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
deviceByState[stateKey]!.add(device);
|
sinkDeviceByState.add(deviceByState);
|
||||||
}
|
}
|
||||||
sinkAllDevices.add(devices);
|
}
|
||||||
sinkDeviceByState.add(deviceByState);
|
|
||||||
|
sinkAllDevices.add(devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getStateKey(int state) {
|
||||||
|
switch (state) {
|
||||||
|
case -1:
|
||||||
|
return ApplicationConstants.OFFLINE_STATE;
|
||||||
|
case 0:
|
||||||
|
return ApplicationConstants.NORMAL_STATE;
|
||||||
|
case 1:
|
||||||
|
return ApplicationConstants.WARNING_STATE;
|
||||||
|
case 2:
|
||||||
|
return ApplicationConstants.INPROGRESS_STATE;
|
||||||
|
default:
|
||||||
|
return ApplicationConstants.ERROR_STATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:sfm_app/product/base/bloc/base_bloc.dart';
|
import '../product/base/bloc/base_bloc.dart';
|
||||||
|
import '../product/services/api_services.dart';
|
||||||
import '../feature/bell/bell_model.dart';
|
import '../feature/bell/bell_model.dart';
|
||||||
|
import '../feature/settings/profile/profile_model.dart';
|
||||||
|
|
||||||
class MainBloc extends BlocBase {
|
class MainBloc extends BlocBase {
|
||||||
|
APIServices apiServices = APIServices();
|
||||||
final bellBloc = StreamController<Bell>.broadcast();
|
final bellBloc = StreamController<Bell>.broadcast();
|
||||||
StreamSink<Bell> get sinkBellBloc => bellBloc.sink;
|
StreamSink<Bell> get sinkBellBloc => bellBloc.sink;
|
||||||
Stream<Bell> get streamBellBloc => bellBloc.stream;
|
Stream<Bell> get streamBellBloc => bellBloc.stream;
|
||||||
|
|
||||||
|
|
||||||
final language = StreamController<Locale?>.broadcast();
|
final language = StreamController<Locale?>.broadcast();
|
||||||
StreamSink<Locale?> get sinkLanguage => language.sink;
|
StreamSink<Locale?> get sinkLanguage => language.sink;
|
||||||
Stream<Locale?> get streamLanguage => language.stream;
|
Stream<Locale?> get streamLanguage => language.stream;
|
||||||
|
|
||||||
final theme = StreamController<ThemeData?>.broadcast();
|
final theme = StreamController<ThemeData?>.broadcast();
|
||||||
StreamSink<ThemeData?> get sinkTheme => theme.sink;
|
StreamSink<ThemeData?> get sinkTheme => theme.sink;
|
||||||
Stream<ThemeData?> get streamTheme => theme.stream;
|
Stream<ThemeData?> get streamTheme => theme.stream;
|
||||||
@@ -26,6 +29,16 @@ class MainBloc extends BlocBase {
|
|||||||
StreamSink<bool> get sinkIsVNIcon => isVNIcon.sink;
|
StreamSink<bool> get sinkIsVNIcon => isVNIcon.sink;
|
||||||
Stream<bool> get streamIsVNIcon => isVNIcon.stream;
|
Stream<bool> get streamIsVNIcon => isVNIcon.stream;
|
||||||
|
|
||||||
|
final userProfile = StreamController<User>.broadcast();
|
||||||
|
StreamSink<User> get sinkUserProfile => userProfile.sink;
|
||||||
|
Stream<User> get streamUserProfile => userProfile.stream;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {}
|
void dispose() {}
|
||||||
|
|
||||||
|
void getUserProfile() async {
|
||||||
|
String data = await apiServices.getUserDetail();
|
||||||
|
User user = User.fromJson(jsonDecode(data));
|
||||||
|
sinkUserProfile.add(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,27 +92,41 @@ class _BellScreenState extends State<BellScreen> {
|
|||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
Container(
|
||||||
title: Text(
|
decoration: BoxDecoration(
|
||||||
getBellEvent(
|
color: bellSnapshot
|
||||||
context,
|
.data![index].status! ==
|
||||||
bellSnapshot.data![index]
|
1
|
||||||
.itemDetail!.sourceName!,
|
? Theme.of(context)
|
||||||
bellSnapshot
|
.appBarTheme
|
||||||
.data![index].eventType!,
|
.backgroundColor
|
||||||
bellSnapshot.data![index]
|
: Theme.of(context)
|
||||||
.itemDetail!.targetName!,
|
.colorScheme
|
||||||
),
|
.outlineVariant,
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 3,
|
|
||||||
style:
|
|
||||||
const TextStyle(fontSize: 15),
|
|
||||||
),
|
),
|
||||||
trailing: Text(
|
child: ListTile(
|
||||||
timeAgo(
|
// style: ListTileS,
|
||||||
context,
|
title: Text(
|
||||||
bellSnapshot
|
getBellEvent(
|
||||||
.data![index].createdAt!,
|
context,
|
||||||
|
bellSnapshot.data![index]
|
||||||
|
.itemDetail!.sourceName!,
|
||||||
|
bellSnapshot
|
||||||
|
.data![index].eventType!,
|
||||||
|
bellSnapshot.data![index]
|
||||||
|
.itemDetail!.targetName!,
|
||||||
|
),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 3,
|
||||||
|
style:
|
||||||
|
const TextStyle(fontSize: 15),
|
||||||
|
),
|
||||||
|
trailing: Text(
|
||||||
|
timeAgo(
|
||||||
|
context,
|
||||||
|
bellSnapshot
|
||||||
|
.data![index].createdAt!,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -176,26 +190,6 @@ class _BellScreenState extends State<BellScreen> {
|
|||||||
check = false;
|
check = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkStatus(List<BellItems> bells) {
|
|
||||||
for (var bell in bells) {
|
|
||||||
if (bell.status == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Color> colorByTheme(int status) async {
|
|
||||||
String theme = await apiServices.checkTheme();
|
|
||||||
if (theme == AppThemes.LIGHT.name && status == 1) {
|
|
||||||
return Colors.white;
|
|
||||||
} else if (theme == AppThemes.DARK.name && status == 1) {
|
|
||||||
return Colors.black;
|
|
||||||
} else {
|
|
||||||
return const Color.fromARGB(255, 90, 175, 214);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String timeAgo(BuildContext context, DateTime dateTime) {
|
String timeAgo(BuildContext context, DateTime dateTime) {
|
||||||
final duration = DateTime.now().difference(dateTime);
|
final duration = DateTime.now().difference(dateTime);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sfm_app/product/shared/shared_snack_bar.dart';
|
||||||
import '../../product/utils/response_status_utils.dart';
|
import '../../product/utils/response_status_utils.dart';
|
||||||
import '../../product/constant/enums/role_enums.dart';
|
import '../../product/constant/enums/role_enums.dart';
|
||||||
import '../../product/services/api_services.dart';
|
import '../../product/services/api_services.dart';
|
||||||
@@ -22,8 +23,11 @@ addNewDevice(BuildContext context, String role) async {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text('${appLocalization(context).add_device_title}: ',
|
Text(
|
||||||
style: context.titleMediumTextStyle),
|
'${appLocalization(context).add_device_title}: ',
|
||||||
|
style:
|
||||||
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
@@ -57,15 +61,28 @@ addNewDevice(BuildContext context, String role) async {
|
|||||||
appLocalization(context).input_name_device_hintText),
|
appLocalization(context).input_name_device_hintText),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
|
SizedBox(
|
||||||
|
height: context.lowValue,
|
||||||
|
),
|
||||||
Center(
|
Center(
|
||||||
child: TextButton(
|
child: FilledButton.tonal(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
String extID = extIDController.text;
|
String extID = extIDController.text;
|
||||||
String deviceName = deviceNameController.text;
|
String deviceName = deviceNameController.text;
|
||||||
|
if (extID == "") {
|
||||||
|
showNoIconTopSnackBar(
|
||||||
|
context,
|
||||||
|
appLocalization(context).notification_enter_all_inf,
|
||||||
|
Colors.orange,
|
||||||
|
Colors.white);
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
} else {
|
||||||
addDevices(context, role, extID, deviceName);
|
addDevices(context, role, extID, deviceName);
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
},
|
}
|
||||||
child: Text(appLocalization(context).add_button_content)),
|
},
|
||||||
|
child: Text(appLocalization(context).add_button_content),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -29,17 +29,17 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
|
|||||||
APIServices apiServices = APIServices();
|
APIServices apiServices = APIServices();
|
||||||
List<Device> devices = [];
|
List<Device> devices = [];
|
||||||
Timer? getAllDevicesTimer;
|
Timer? getAllDevicesTimer;
|
||||||
|
List<Widget> tags = [];
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
devicesManagerBloc = BlocProvider.of(context);
|
devicesManagerBloc = BlocProvider.of(context);
|
||||||
getUserRole();
|
getUserRole();
|
||||||
// devicesManagerBloc.getDevice();
|
const duration = Duration(seconds: 10);
|
||||||
// getAllOwnerDevices();
|
getAllDevicesTimer = Timer.periodic(
|
||||||
// const duration = Duration(seconds: 10);
|
duration,
|
||||||
// getAllDevicesTimer =
|
(Timer t) => devicesManagerBloc.getDeviceByState(-2),
|
||||||
// Timer.periodic(duration, (Timer t) => devicesManagerBloc.getDevice());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -52,144 +52,179 @@ class _DevicesManagerScreenState extends State<DevicesManagerScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
// backgroundColor: Colors.grey.withValues(alpha: 0.6),
|
// backgroundColor: Colors.grey.withValues(alpha: 0.6),
|
||||||
body: SafeArea(
|
body: StreamBuilder<List<int>>(
|
||||||
child: StreamBuilder<List<Device>>(
|
stream: devicesManagerBloc.streamTagStates,
|
||||||
stream: devicesManagerBloc.streamAllDevices,
|
builder: (context, tagSnapshot) {
|
||||||
initialData: devices,
|
return SafeArea(
|
||||||
builder: (context, allDeviceSnapshot) {
|
child: StreamBuilder<List<Device>>(
|
||||||
if (allDeviceSnapshot.data?.isEmpty ?? devices.isEmpty) {
|
stream: devicesManagerBloc.streamAllDevices,
|
||||||
devicesManagerBloc.getDevice();
|
initialData: devices,
|
||||||
return const Center(child: CircularProgressIndicator());
|
builder: (context, allDeviceSnapshot) {
|
||||||
} else {
|
if (allDeviceSnapshot.data?.isEmpty ?? devices.isEmpty) {
|
||||||
return SingleChildScrollView(
|
devicesManagerBloc
|
||||||
child: Column(
|
.getDeviceByState(tagSnapshot.data?[0] ?? -2);
|
||||||
children: [
|
return const Center(child: CircularProgressIndicator());
|
||||||
StreamBuilder<String>(
|
} else {
|
||||||
stream: devicesManagerBloc.streamUserRole,
|
if (tagSnapshot.data!.isNotEmpty) {}
|
||||||
initialData: role,
|
return SingleChildScrollView(
|
||||||
builder: (context, roleSnapshot) {
|
child: Column(
|
||||||
return PaginatedDataTable(
|
children: [
|
||||||
header: Center(
|
if (tagSnapshot.hasData &&
|
||||||
child: Text(
|
tagSnapshot.data!.isNotEmpty &&
|
||||||
appLocalization(context)
|
tagSnapshot.data![0] != -2)
|
||||||
.paginated_data_table_title,
|
TagState(
|
||||||
style: context.titleLargeTextStyle,
|
state: tagSnapshot.data![0],
|
||||||
|
devicesManagerBloc: devicesManagerBloc,
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: context.lowValue),
|
||||||
columns: [
|
StreamBuilder<String>(
|
||||||
if (roleSnapshot.data == RoleEnums.ADMIN.name ||
|
stream: devicesManagerBloc.streamUserRole,
|
||||||
roleSnapshot.data == RoleEnums.USER.name)
|
initialData: role,
|
||||||
DataColumn(
|
builder: (context, roleSnapshot) {
|
||||||
label: Center(
|
return CardTheme(
|
||||||
child: Text(appLocalization(context)
|
color: Theme.of(context).colorScheme.onPrimary,
|
||||||
.paginated_data_table_column_action),
|
shadowColor:
|
||||||
),
|
Theme.of(context).colorScheme.onPrimary,
|
||||||
),
|
child: PaginatedDataTable(
|
||||||
DataColumn(
|
headingRowHeight: 30,
|
||||||
label: Center(
|
columnSpacing: 30,
|
||||||
child: Text(appLocalization(context)
|
horizontalMargin: 10,
|
||||||
.paginated_data_table_column_deviceName),
|
header: Center(
|
||||||
),
|
child: Text(
|
||||||
),
|
appLocalization(context)
|
||||||
DataColumn(
|
.paginated_data_table_title,
|
||||||
label: Center(
|
style: context.headlineMediumTextStyle,
|
||||||
child: Text(appLocalization(context)
|
),
|
||||||
.paginated_data_table_column_deviceStatus),
|
),
|
||||||
),
|
columns: [
|
||||||
),
|
if (roleSnapshot.data ==
|
||||||
DataColumn(
|
RoleEnums.ADMIN.name ||
|
||||||
label: Center(
|
roleSnapshot.data ==
|
||||||
child: Text(appLocalization(context)
|
RoleEnums.USER.name)
|
||||||
.paginated_data_table_column_deviceBaterry),
|
DataColumn(
|
||||||
),
|
label: Center(
|
||||||
),
|
child: Text(appLocalization(context)
|
||||||
DataColumn(
|
.paginated_data_table_column_deviceName),
|
||||||
label: Center(
|
),
|
||||||
child: Text(appLocalization(context)
|
),
|
||||||
.paginated_data_table_column_deviceSignal),
|
DataColumn(
|
||||||
),
|
label: Center(
|
||||||
),
|
child: Text(appLocalization(context)
|
||||||
DataColumn(
|
.paginated_data_table_column_deviceStatus),
|
||||||
label: Center(
|
),
|
||||||
child: Text(appLocalization(context)
|
),
|
||||||
.paginated_data_table_column_deviceTemperature),
|
DataColumn(
|
||||||
),
|
label: Center(
|
||||||
),
|
child: Text(appLocalization(context)
|
||||||
DataColumn(
|
.paginated_data_table_column_deviceBaterry),
|
||||||
label: Center(
|
),
|
||||||
child: Text(appLocalization(context)
|
),
|
||||||
.paginated_data_table_column_deviceHump),
|
DataColumn(
|
||||||
),
|
label: Center(
|
||||||
),
|
child: Text(appLocalization(context)
|
||||||
DataColumn(
|
.paginated_data_table_column_deviceSignal),
|
||||||
label: Center(
|
),
|
||||||
child: Text(appLocalization(context)
|
),
|
||||||
.paginated_data_table_column_devicePower),
|
DataColumn(
|
||||||
),
|
label: Center(
|
||||||
),
|
child: Text(appLocalization(context)
|
||||||
],
|
.paginated_data_table_column_deviceTemperature),
|
||||||
onPageChanged: (int pageIndex) {
|
),
|
||||||
// log('Chuyen page: $pageIndex');
|
),
|
||||||
},
|
DataColumn(
|
||||||
rowsPerPage: 5,
|
label: Center(
|
||||||
actions: [
|
child: Text(appLocalization(context)
|
||||||
if (roleSnapshot.data == RoleEnums.USER.name ||
|
.paginated_data_table_column_deviceHump),
|
||||||
roleSnapshot.data == RoleEnums.ADMIN.name)
|
),
|
||||||
IconButton(
|
),
|
||||||
style: ButtonStyle(
|
DataColumn(
|
||||||
backgroundColor:
|
label: Center(
|
||||||
WidgetStateProperty.all<Color>(
|
child: Text(appLocalization(context)
|
||||||
Colors.green),
|
.paginated_data_table_column_devicePower),
|
||||||
iconColor: WidgetStateProperty.all<Color>(
|
),
|
||||||
Colors.white)),
|
),
|
||||||
onPressed: () {
|
DataColumn(
|
||||||
ScaffoldMessenger.of(context)
|
label: Center(
|
||||||
.clearSnackBars();
|
child: Text(appLocalization(context)
|
||||||
addNewDevice(
|
.paginated_data_table_column_action),
|
||||||
context, roleSnapshot.data ?? role);
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onPageChanged: (int pageIndex) {
|
||||||
|
// log('Chuyen page: $pageIndex');
|
||||||
},
|
},
|
||||||
icon: IconConstants.instance
|
rowsPerPage:
|
||||||
.getMaterialIcon(Icons.add))
|
(allDeviceSnapshot.data?.length ?? 0) < 6
|
||||||
],
|
? (allDeviceSnapshot.data?.length ??
|
||||||
source: DeviceSource(
|
0)
|
||||||
devices: allDeviceSnapshot.data ?? devices,
|
: 5,
|
||||||
context: context,
|
actions: [
|
||||||
devicesBloc: devicesManagerBloc,
|
if (roleSnapshot.data ==
|
||||||
role: role,
|
RoleEnums.USER.name ||
|
||||||
|
roleSnapshot.data ==
|
||||||
|
RoleEnums.ADMIN.name)
|
||||||
|
IconButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor:
|
||||||
|
WidgetStateProperty.all<Color>(
|
||||||
|
Colors.green),
|
||||||
|
iconColor:
|
||||||
|
WidgetStateProperty.all<Color>(
|
||||||
|
Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.clearSnackBars();
|
||||||
|
addNewDevice(context,
|
||||||
|
roleSnapshot.data ?? role);
|
||||||
|
},
|
||||||
|
icon: IconConstants.instance
|
||||||
|
.getMaterialIcon(Icons.add))
|
||||||
|
],
|
||||||
|
source: DeviceSource(
|
||||||
|
devices: allDeviceSnapshot.data ?? devices,
|
||||||
|
context: context,
|
||||||
|
devicesBloc: devicesManagerBloc,
|
||||||
|
role: role,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
SizedBox(height: context.lowValue),
|
||||||
},
|
Text(
|
||||||
),
|
appLocalization(context).overview_message,
|
||||||
SizedBox(height: context.lowValue),
|
style: const TextStyle(
|
||||||
Text(
|
fontSize: 20,
|
||||||
appLocalization(context).overview_message,
|
fontWeight: FontWeight.bold,
|
||||||
style: const TextStyle(
|
),
|
||||||
fontSize: 20,
|
),
|
||||||
fontWeight: FontWeight.bold,
|
StreamBuilder<Map<String, List<Device>>>(
|
||||||
|
stream: devicesManagerBloc.streamDeviceByState,
|
||||||
|
builder: (context, devicesByStateSnapshot) {
|
||||||
|
if (devicesByStateSnapshot.data == null) {
|
||||||
|
devicesManagerBloc.getDeviceByState(
|
||||||
|
tagSnapshot.data?[0] ?? -2);
|
||||||
|
return const Center(
|
||||||
|
child: CircularProgressIndicator());
|
||||||
|
} else {
|
||||||
|
return SharedPieChart(
|
||||||
|
deviceByState:
|
||||||
|
devicesByStateSnapshot.data ?? {},
|
||||||
|
devicesManagerBloc: devicesManagerBloc,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
SizedBox(height: context.lowValue),
|
}
|
||||||
StreamBuilder<Map<String, List<Device>>>(
|
},
|
||||||
stream: devicesManagerBloc.streamDeviceByState,
|
),
|
||||||
builder: (context, devicesByStateSnapshot) {
|
);
|
||||||
if (devicesByStateSnapshot.data == null) {
|
}),
|
||||||
devicesManagerBloc.getDevice();
|
|
||||||
return const Center(
|
|
||||||
child: CircularProgressIndicator());
|
|
||||||
} else {
|
|
||||||
return SharedPieChart(
|
|
||||||
deviceByState: devicesByStateSnapshot.data ?? {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(height: context.mediumValue),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,11 +240,13 @@ class DeviceSource extends DataTableSource {
|
|||||||
List<Device> devices;
|
List<Device> devices;
|
||||||
final DevicesManagerBloc devicesBloc;
|
final DevicesManagerBloc devicesBloc;
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
DeviceSource(
|
|
||||||
{required this.devices,
|
DeviceSource({
|
||||||
required this.context,
|
required this.devices,
|
||||||
required this.devicesBloc,
|
required this.context,
|
||||||
required this.role});
|
required this.devicesBloc,
|
||||||
|
required this.role,
|
||||||
|
});
|
||||||
@override
|
@override
|
||||||
DataRow? getRow(int index) {
|
DataRow? getRow(int index) {
|
||||||
if (index >= devices.length) {
|
if (index >= devices.length) {
|
||||||
@@ -221,88 +258,72 @@ class DeviceSource extends DataTableSource {
|
|||||||
String deviceState =
|
String deviceState =
|
||||||
DeviceUtils.instance.checkStateDevice(context, device.state!);
|
DeviceUtils.instance.checkStateDevice(context, device.state!);
|
||||||
return DataRow.byIndex(
|
return DataRow.byIndex(
|
||||||
// color: getTableRowColor(device.state!),
|
// color: WidgetStateProperty.all(rowColor),
|
||||||
index: index,
|
index: index,
|
||||||
cells: [
|
cells: [
|
||||||
if (role == RoleEnums.USER.name || role == RoleEnums.ADMIN.name)
|
if (role == RoleEnums.USER.name || role == RoleEnums.ADMIN.name)
|
||||||
DataCell(
|
DataCell(
|
||||||
Center(
|
Text(device.name!,
|
||||||
child: Row(
|
style: TextStyle(
|
||||||
children: [
|
color: DeviceUtils.instance
|
||||||
IconButton(
|
.getTableRowColor(device.state!))), onTap: () {
|
||||||
// style: ButtonStyle(),
|
context.pushNamed(AppRoutes.DEVICE_DETAIL.name,
|
||||||
hoverColor: Colors.black,
|
pathParameters: {'thingID': device.thingId!});
|
||||||
onPressed: () {
|
}),
|
||||||
context.pushNamed(AppRoutes.DEVICE_UPDATE.name,
|
|
||||||
pathParameters: {'thingID': device.thingId!});
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.build, color: Colors.blue)),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () async {
|
|
||||||
handleDeleteDevice(context, device.thingId!, role);
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.delete, color: Colors.red)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
DataCell(
|
DataCell(
|
||||||
Text(device.name!,
|
Text(deviceState,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: DeviceUtils.instance
|
color: DeviceUtils.instance
|
||||||
.getTableRowColor(device.state!))), onTap: () {
|
.getTableRowColor(device.state!))), onTap: () {
|
||||||
// log(device.thingId.toString());
|
|
||||||
context.pushNamed(AppRoutes.DEVICE_DETAIL.name,
|
context.pushNamed(AppRoutes.DEVICE_DETAIL.name,
|
||||||
pathParameters: {'thingID': device.thingId!});
|
pathParameters: {'thingID': device.thingId!});
|
||||||
}),
|
}),
|
||||||
DataCell(
|
DataCell(
|
||||||
Center(
|
Text(sensorMap['sensorBattery'] + "%",
|
||||||
child: Text(deviceState,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
color: DeviceUtils.instance.getTableRowColor(device.state!))),
|
||||||
color: DeviceUtils.instance
|
|
||||||
.getTableRowColor(device.state!)))), onTap: () {
|
|
||||||
// log(device.thingId.toString());
|
|
||||||
context.pushNamed(AppRoutes.DEVICE_DETAIL.name,
|
|
||||||
pathParameters: {'thingID': device.thingId!});
|
|
||||||
}),
|
|
||||||
DataCell(
|
|
||||||
Center(
|
|
||||||
child: Center(
|
|
||||||
child: Text(sensorMap['sensorBattery'] + "%",
|
|
||||||
style: TextStyle(
|
|
||||||
color: DeviceUtils.instance
|
|
||||||
.getTableRowColor(device.state!))))),
|
|
||||||
onTap: () => context.pushNamed(AppRoutes.DEVICE_DETAIL.name,
|
onTap: () => context.pushNamed(AppRoutes.DEVICE_DETAIL.name,
|
||||||
pathParameters: {'thingID': device.thingId!}),
|
pathParameters: {'thingID': device.thingId!}),
|
||||||
),
|
),
|
||||||
DataCell(
|
DataCell(
|
||||||
Center(
|
Text(sensorMap['sensorCsq'],
|
||||||
child: Center(
|
style: TextStyle(
|
||||||
child: Text(sensorMap['sensorCsq'],
|
color: DeviceUtils.instance.getTableRowColor(device.state!))),
|
||||||
style: TextStyle(
|
),
|
||||||
color: DeviceUtils.instance
|
DataCell(
|
||||||
.getTableRowColor(device.state!))))),
|
Text("${sensorMap['sensorTemp']}°C",
|
||||||
|
style: TextStyle(
|
||||||
|
color: DeviceUtils.instance.getTableRowColor(device.state!))),
|
||||||
|
),
|
||||||
|
DataCell(
|
||||||
|
Text("${sensorMap['sensorHum']}%",
|
||||||
|
style: TextStyle(
|
||||||
|
color: DeviceUtils.instance.getTableRowColor(device.state!))),
|
||||||
|
),
|
||||||
|
DataCell(
|
||||||
|
Text("${sensorMap['sensorVolt']}V",
|
||||||
|
style: TextStyle(
|
||||||
|
color: DeviceUtils.instance.getTableRowColor(device.state!))),
|
||||||
),
|
),
|
||||||
DataCell(
|
DataCell(
|
||||||
Center(
|
Center(
|
||||||
child: Text(sensorMap['sensorTemp'],
|
child: Row(
|
||||||
style: TextStyle(
|
children: [
|
||||||
color: DeviceUtils.instance
|
IconButton(
|
||||||
.getTableRowColor(device.state!)))),
|
hoverColor: Colors.black,
|
||||||
),
|
onPressed: () {
|
||||||
DataCell(
|
context.pushNamed(AppRoutes.DEVICE_UPDATE.name,
|
||||||
Center(
|
pathParameters: {'thingID': device.thingId!});
|
||||||
child: Text(sensorMap['sensorHum'],
|
},
|
||||||
style: TextStyle(
|
icon: const Icon(Icons.build, color: Colors.blue)),
|
||||||
color: DeviceUtils.instance
|
IconButton(
|
||||||
.getTableRowColor(device.state!)))),
|
onPressed: () async {
|
||||||
),
|
handleDeleteDevice(context, device.thingId!, role);
|
||||||
DataCell(
|
},
|
||||||
Center(
|
icon: const Icon(Icons.delete, color: Colors.red)),
|
||||||
child: Text(sensorMap['sensorVolt'],
|
],
|
||||||
style: TextStyle(
|
),
|
||||||
color: DeviceUtils.instance
|
),
|
||||||
.getTableRowColor(device.state!)))),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -317,3 +338,44 @@ class DeviceSource extends DataTableSource {
|
|||||||
@override
|
@override
|
||||||
int get selectedRowCount => 0;
|
int get selectedRowCount => 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TagState extends StatelessWidget {
|
||||||
|
const TagState({
|
||||||
|
super.key,
|
||||||
|
required this.state,
|
||||||
|
required this.devicesManagerBloc,
|
||||||
|
});
|
||||||
|
|
||||||
|
final int state;
|
||||||
|
final DevicesManagerBloc devicesManagerBloc;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: EdgeInsets.all(context.lowValue),
|
||||||
|
height: context.mediumValue,
|
||||||
|
width: context.dynamicWidth(0.35),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: DeviceUtils.instance.getTableRowColor(state),
|
||||||
|
borderRadius: BorderRadius.circular(context.mediumValue),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
DeviceUtils.instance.checkStateDevice(context, state),
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
devicesManagerBloc.getDeviceByState(-2);
|
||||||
|
},
|
||||||
|
child: const Icon(
|
||||||
|
Icons.close,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
homeBloc = BlocProvider.of(context);
|
homeBloc = BlocProvider.of(context);
|
||||||
const duration = Duration(seconds: 20);
|
|
||||||
getOwnerAndJoinedDevices();
|
getOwnerAndJoinedDevices();
|
||||||
|
const duration = Duration(seconds: 20);
|
||||||
getAllDevicesTimer =
|
getAllDevicesTimer =
|
||||||
Timer.periodic(duration, (Timer t) => getOwnerAndJoinedDevices());
|
Timer.periodic(duration, (Timer t) => getOwnerAndJoinedDevices());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import 'package:go_router/go_router.dart';
|
|||||||
// import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart';
|
// import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart';
|
||||||
import 'package:badges/badges.dart' as badges;
|
import 'package:badges/badges.dart' as badges;
|
||||||
import 'package:persistent_bottom_nav_bar/persistent_bottom_nav_bar.dart';
|
import 'package:persistent_bottom_nav_bar/persistent_bottom_nav_bar.dart';
|
||||||
|
import '../settings/profile/profile_model.dart';
|
||||||
|
import '../../product/extention/context_extention.dart';
|
||||||
import '../../bloc/home_bloc.dart';
|
import '../../bloc/home_bloc.dart';
|
||||||
import '../../product/constant/app/app_constants.dart';
|
import '../../product/constant/app/app_constants.dart';
|
||||||
import '../../product/constant/enums/app_route_enums.dart';
|
import '../../product/constant/enums/app_route_enums.dart';
|
||||||
@@ -75,6 +77,7 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
|||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
initialCheck();
|
initialCheck();
|
||||||
getBellNotification();
|
getBellNotification();
|
||||||
|
mainBloc.getUserProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -176,36 +179,21 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
|||||||
builder: (context, themeModeSnapshot) {
|
builder: (context, themeModeSnapshot) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
title: StreamBuilder<User>(
|
||||||
|
stream: mainBloc.streamUserProfile,
|
||||||
|
builder: (context, userSnapshot) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
IconConstants.instance.getMaterialIcon(Icons.person),
|
||||||
|
SizedBox(
|
||||||
|
width: context.lowValue,
|
||||||
|
),
|
||||||
|
Text(userSnapshot.data?.name ?? "")
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
actions: [
|
actions: [
|
||||||
// LightDarkSwitch(
|
|
||||||
// value: !isLight,
|
|
||||||
// onChanged: (value) {
|
|
||||||
// themeNotifier.changeTheme();
|
|
||||||
// isLight = !isLight;
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// SizedBox(
|
|
||||||
// width: context.lowValue,
|
|
||||||
// ),
|
|
||||||
// StreamBuilder<bool>(
|
|
||||||
// stream: mainBloc.streamIsVNIcon,
|
|
||||||
// builder: (context, isVNSnapshot) {
|
|
||||||
// return LanguageSwitch(
|
|
||||||
// value: isVNSnapshot.data ?? isVN,
|
|
||||||
// onChanged: (value) async {
|
|
||||||
// Locale locale = await LanguageServices().setLocale(isVN
|
|
||||||
// ? LanguageConstants.ENGLISH
|
|
||||||
// : LanguageConstants.VIETNAM);
|
|
||||||
// MyApp.setLocale(context, locale);
|
|
||||||
// isVN = !isVN;
|
|
||||||
// mainBloc.sinkIsVNIcon.add(isVN);
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
// }),
|
|
||||||
// SizedBox(
|
|
||||||
// width: context.lowValue,
|
|
||||||
// ),
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
ThemeData newTheme = await ThemeServices().changeTheme(
|
ThemeData newTheme = await ThemeServices().changeTheme(
|
||||||
@@ -337,11 +325,9 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
screens: _buildScreens(),
|
screens: _buildScreens(),
|
||||||
items: _navBarsItems(),
|
items: _navBarsItems(),
|
||||||
// confineInSafeArea: true,
|
|
||||||
handleAndroidBackButtonPress: true,
|
handleAndroidBackButtonPress: true,
|
||||||
resizeToAvoidBottomInset: true,
|
resizeToAvoidBottomInset: true,
|
||||||
stateManagement: true,
|
stateManagement: true,
|
||||||
// hideNavigationBarWhenKeyboardShows: true,
|
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
themeModeSnapshot.data! ? Colors.white : Colors.black,
|
themeModeSnapshot.data! ? Colors.white : Colors.black,
|
||||||
decoration: NavBarDecoration(
|
decoration: NavBarDecoration(
|
||||||
@@ -349,17 +335,18 @@ class _MainScreenState extends State<MainScreen> with WidgetsBindingObserver {
|
|||||||
colorBehindNavBar:
|
colorBehindNavBar:
|
||||||
themeModeSnapshot.data! ? Colors.white : Colors.black,
|
themeModeSnapshot.data! ? Colors.white : Colors.black,
|
||||||
),
|
),
|
||||||
// popAllScreensOnTapOfSelectedTab: true,
|
animationSettings: const NavBarAnimationSettings(
|
||||||
// itemAnimationProperties: const ItemAnimationProperties(
|
navBarItemAnimation: ItemAnimationSettings(
|
||||||
// duration: Duration(milliseconds: 200),
|
duration: Duration(milliseconds: 200),
|
||||||
// curve: Curves.bounceInOut,
|
curve: Curves.bounceInOut,
|
||||||
// ),
|
),
|
||||||
// screenTransitionAnimation: const ScreenTransitionAnimation(
|
screenTransitionAnimation: ScreenTransitionAnimationSettings(
|
||||||
// animateTabTransition: true,
|
animateTabTransition: true,
|
||||||
// curve: Curves.linear,
|
curve: Curves.bounceInOut,
|
||||||
// duration: Duration(milliseconds: 200),
|
duration: Duration(milliseconds: 200),
|
||||||
// ),
|
),
|
||||||
navBarStyle: NavBarStyle.style4,
|
),
|
||||||
|
navBarStyle: NavBarStyle.style13,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ extension PageExtension on BuildContext {
|
|||||||
extension DurationExtension on BuildContext {
|
extension DurationExtension on BuildContext {
|
||||||
Duration get lowDuration => const Duration(milliseconds: 150);
|
Duration get lowDuration => const Duration(milliseconds: 150);
|
||||||
Duration get normalDuration => const Duration(milliseconds: 500);
|
Duration get normalDuration => const Duration(milliseconds: 500);
|
||||||
Duration dynamicMilliSecondDuration(int milliseconds) => Duration(milliseconds: milliseconds);
|
Duration dynamicMilliSecondDuration(int milliseconds) =>
|
||||||
|
Duration(milliseconds: milliseconds);
|
||||||
Duration dynamicMinutesDuration(int minutes) => Duration(minutes: minutes);
|
Duration dynamicMinutesDuration(int minutes) => Duration(minutes: minutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class NetworkManager {
|
|||||||
/// string if the request fails
|
/// string if the request fails
|
||||||
Future<String> getDataFromServer(String path) async {
|
Future<String> getDataFromServer(String path) async {
|
||||||
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
||||||
log("GET url: $url");
|
log("[${DateTime.now().toLocal().toString().split(' ')[1]}] GET url: $url");
|
||||||
final headers = await getHeaders();
|
final headers = await getHeaders();
|
||||||
final response = await http.get(url, headers: headers);
|
final response = await http.get(url, headers: headers);
|
||||||
if (response.statusCode == StatusCodeConstants.OK ||
|
if (response.statusCode == StatusCodeConstants.OK ||
|
||||||
@@ -61,7 +61,7 @@ class NetworkManager {
|
|||||||
Future<String> getDataFromServerWithParams(
|
Future<String> getDataFromServerWithParams(
|
||||||
String path, Map<String, dynamic> params) async {
|
String path, Map<String, dynamic> params) async {
|
||||||
final url = Uri.https(ApplicationConstants.DOMAIN, path, params);
|
final url = Uri.https(ApplicationConstants.DOMAIN, path, params);
|
||||||
log("GET Params url: $url");
|
log("[${DateTime.now().toLocal().toString().split(' ')[1]}] GET Params url: $url");
|
||||||
final headers = await getHeaders();
|
final headers = await getHeaders();
|
||||||
final response = await http.get(url, headers: headers);
|
final response = await http.get(url, headers: headers);
|
||||||
if (response.statusCode == StatusCodeConstants.CREATED ||
|
if (response.statusCode == StatusCodeConstants.CREATED ||
|
||||||
@@ -78,7 +78,7 @@ class NetworkManager {
|
|||||||
/// to be sent. Returns the HTTP status code of the response.
|
/// to be sent. Returns the HTTP status code of the response.
|
||||||
Future<int> createDataInServer(String path, Map<String, dynamic> body) async {
|
Future<int> createDataInServer(String path, Map<String, dynamic> body) async {
|
||||||
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
||||||
log("POST url: $url");
|
log("[${DateTime.now().toLocal().toString().split(' ')[1]}] POST url: $url");
|
||||||
final headers = await getHeaders();
|
final headers = await getHeaders();
|
||||||
final response =
|
final response =
|
||||||
await http.post(url, headers: headers, body: jsonEncode(body));
|
await http.post(url, headers: headers, body: jsonEncode(body));
|
||||||
@@ -91,7 +91,7 @@ class NetworkManager {
|
|||||||
/// to be updated. Returns the HTTP status code of the response.
|
/// to be updated. Returns the HTTP status code of the response.
|
||||||
Future<int> updateDataInServer(String path, Map<String, dynamic> body) async {
|
Future<int> updateDataInServer(String path, Map<String, dynamic> body) async {
|
||||||
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
||||||
log("PUT url: $url");
|
log("[${DateTime.now().toLocal().toString().split(' ')[1]}] PUT url: $url");
|
||||||
final headers = await getHeaders();
|
final headers = await getHeaders();
|
||||||
final response =
|
final response =
|
||||||
await http.put(url, headers: headers, body: jsonEncode(body));
|
await http.put(url, headers: headers, body: jsonEncode(body));
|
||||||
@@ -106,7 +106,7 @@ class NetworkManager {
|
|||||||
/// failure or an error.
|
/// failure or an error.
|
||||||
Future<int> deleteDataInServer(String path) async {
|
Future<int> deleteDataInServer(String path) async {
|
||||||
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
final url = Uri.https(ApplicationConstants.DOMAIN, path);
|
||||||
log("DELETE url: $url");
|
log("[${DateTime.now().toLocal().toString().split(' ')[1]}] DELETE url: $url");
|
||||||
final headers = await getHeaders();
|
final headers = await getHeaders();
|
||||||
final response = await http.delete(url, headers: headers);
|
final response = await http.delete(url, headers: headers);
|
||||||
return response.statusCode;
|
return response.statusCode;
|
||||||
|
|||||||
@@ -271,6 +271,12 @@ class APIServices {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> getOwnerDevieByState(Map<String, dynamic> params) async {
|
||||||
|
String? data = await NetworkManager.instance!
|
||||||
|
.getDataFromServerWithParams(APIPathConstants.DEVICE_PATH, params);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> createDeviceByAdmin(Map<String, dynamic> body) async {
|
Future<int> createDeviceByAdmin(Map<String, dynamic> body) async {
|
||||||
int? statusCode = await NetworkManager.instance!
|
int? statusCode = await NetworkManager.instance!
|
||||||
.createDataInServer(APIPathConstants.DEVICE_PATH, body);
|
.createDataInServer(APIPathConstants.DEVICE_PATH, body);
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:fl_chart/fl_chart.dart';
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:sfm_app/bloc/devices_manager_bloc.dart';
|
||||||
import 'package:sfm_app/feature/devices/device_model.dart';
|
import 'package:sfm_app/feature/devices/device_model.dart';
|
||||||
import 'package:sfm_app/product/extention/context_extention.dart';
|
import 'package:sfm_app/product/extention/context_extention.dart';
|
||||||
import 'package:sfm_app/product/services/language_services.dart';
|
import 'package:sfm_app/product/services/language_services.dart';
|
||||||
@@ -7,15 +10,17 @@ import 'package:sfm_app/product/services/language_services.dart';
|
|||||||
import '../constant/app/app_constants.dart';
|
import '../constant/app/app_constants.dart';
|
||||||
|
|
||||||
class SharedPieChart extends StatelessWidget {
|
class SharedPieChart extends StatelessWidget {
|
||||||
const SharedPieChart({
|
const SharedPieChart(
|
||||||
super.key,
|
{super.key,
|
||||||
required this.deviceByState,
|
required this.deviceByState,
|
||||||
});
|
required this.devicesManagerBloc});
|
||||||
|
|
||||||
final Map<String, List<Device>> deviceByState;
|
final Map<String, List<Device>> deviceByState;
|
||||||
|
final DevicesManagerBloc devicesManagerBloc;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
int touchedIndex = -1;
|
||||||
TextStyle titleStyle = const TextStyle(
|
TextStyle titleStyle = const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
@@ -31,56 +36,98 @@ class SharedPieChart extends StatelessWidget {
|
|||||||
deviceByState[ApplicationConstants.INPROGRESS_STATE]?.length ?? 0;
|
deviceByState[ApplicationConstants.INPROGRESS_STATE]?.length ?? 0;
|
||||||
int errorCount =
|
int errorCount =
|
||||||
deviceByState[ApplicationConstants.ERROR_STATE]?.length ?? 0;
|
deviceByState[ApplicationConstants.ERROR_STATE]?.length ?? 0;
|
||||||
return Padding(
|
return AspectRatio(
|
||||||
padding: context.paddingLowHorizontal,
|
aspectRatio: 1.5,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
children: <Widget>[
|
||||||
children: [
|
const SizedBox(
|
||||||
Container(
|
height: 18,
|
||||||
width: context.dynamicWidth(0.5),
|
),
|
||||||
height: context.dynamicHeight(0.3),
|
Expanded(
|
||||||
padding: const EdgeInsets.all(10),
|
child: AspectRatio(
|
||||||
child: PieChart(
|
aspectRatio: 1,
|
||||||
PieChartData(
|
child: PieChart(
|
||||||
sections: [
|
PieChartData(
|
||||||
PieChartSectionData(
|
pieTouchData: PieTouchData(
|
||||||
color: Colors.grey,
|
touchCallback: (FlTouchEvent event, pieTouchResponse) {
|
||||||
value: offlineCount.toDouble(),
|
if (!event.isInterestedForInteractions ||
|
||||||
title: offlineCount.toString(),
|
pieTouchResponse == null ||
|
||||||
radius: context.dynamicWidth(0.2),
|
pieTouchResponse.touchedSection == null) {
|
||||||
titleStyle: titleStyle,
|
touchedIndex = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int newTouchedIndex =
|
||||||
|
pieTouchResponse.touchedSection!.touchedSectionIndex;
|
||||||
|
|
||||||
|
// Chỉ gọi updateDevicesOnTapPieChart nếu touchedIndex thay đổi
|
||||||
|
if (newTouchedIndex != touchedIndex) {
|
||||||
|
touchedIndex = newTouchedIndex;
|
||||||
|
log("TouchedIndex: $touchedIndex");
|
||||||
|
log("Event: ${event.isInterestedForInteractions}");
|
||||||
|
|
||||||
|
Future.delayed(
|
||||||
|
context.lowDuration,
|
||||||
|
() => updateDevicesOnTapPieChart(newTouchedIndex),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// touchedIndex =
|
||||||
|
// pieTouchResponse.touchedSection!.touchedSectionIndex;
|
||||||
|
// // log("TouchedIndex: $touchedIndex");
|
||||||
|
// // log("Event: ${event.isInterestedForInteractions}");
|
||||||
|
// // int currentTouchedIndex = touchedIndex;
|
||||||
|
|
||||||
|
// if (currentTouchedIndex != touchedIndex) {
|
||||||
|
// touchedIndex = currentTouchedIndex;
|
||||||
|
// log("TouchedIndex: $touchedIndex");
|
||||||
|
// log("Event: ${event.isInterestedForInteractions}");
|
||||||
|
|
||||||
|
// Future.delayed(
|
||||||
|
// context.lowDuration,
|
||||||
|
// () => updateDevicesOnTapPieChart(touchedIndex),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
},
|
||||||
),
|
),
|
||||||
PieChartSectionData(
|
sections: [
|
||||||
color: Colors.green,
|
PieChartSectionData(
|
||||||
value: normalCount.toDouble(),
|
color: Colors.grey,
|
||||||
title: normalCount.toString(),
|
value: offlineCount.toDouble(),
|
||||||
radius: context.dynamicWidth(0.2),
|
title: offlineCount.toString(),
|
||||||
titleStyle: titleStyle,
|
radius: context.dynamicWidth(0.2),
|
||||||
),
|
titleStyle: titleStyle,
|
||||||
PieChartSectionData(
|
),
|
||||||
color: Colors.red,
|
PieChartSectionData(
|
||||||
value: warningCount.toDouble(),
|
color: Colors.green,
|
||||||
title: warningCount.toString(),
|
value: normalCount.toDouble(),
|
||||||
radius: context.dynamicWidth(0.2),
|
title: normalCount.toString(),
|
||||||
titleStyle: titleStyle,
|
radius: context.dynamicWidth(0.2),
|
||||||
),
|
titleStyle: titleStyle,
|
||||||
PieChartSectionData(
|
),
|
||||||
color: Colors.yellow,
|
PieChartSectionData(
|
||||||
value: inProgressCount.toDouble(),
|
color: Colors.red,
|
||||||
title: inProgressCount.toString(),
|
value: warningCount.toDouble(),
|
||||||
radius: context.dynamicWidth(0.2),
|
title: warningCount.toString(),
|
||||||
titleStyle: titleStyle,
|
radius: context.dynamicWidth(0.2),
|
||||||
),
|
titleStyle: titleStyle,
|
||||||
PieChartSectionData(
|
),
|
||||||
color: Colors.black, // Có thể thêm màu cho trạng thái lỗi
|
PieChartSectionData(
|
||||||
value: errorCount.toDouble(),
|
color: Colors.yellow,
|
||||||
title: errorCount.toString(),
|
value: inProgressCount.toDouble(),
|
||||||
radius: context.dynamicWidth(0.2),
|
title: inProgressCount.toString(),
|
||||||
titleStyle: titleStyle,
|
radius: context.dynamicWidth(0.2),
|
||||||
),
|
titleStyle: titleStyle,
|
||||||
],
|
),
|
||||||
centerSpaceRadius: context.dynamicWidth(0.1),
|
PieChartSectionData(
|
||||||
sectionsSpace: 2,
|
color: Colors.black, // Có thể thêm màu cho trạng thái lỗi
|
||||||
|
value: errorCount.toDouble(),
|
||||||
|
title: errorCount.toString(),
|
||||||
|
radius: context.dynamicWidth(0.2),
|
||||||
|
titleStyle: titleStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
centerSpaceRadius: context.dynamicWidth(0.05),
|
||||||
|
sectionsSpace: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -88,52 +135,88 @@ class SharedPieChart extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Indicator(
|
if (offlineCount != 0)
|
||||||
color: Colors.grey,
|
Column(
|
||||||
text: appLocalization(context).inactive_devices_message,
|
children: [
|
||||||
isSquare: true,
|
Indicator(
|
||||||
),
|
color: Colors.grey,
|
||||||
SizedBox(
|
text: appLocalization(context).inactive_devices_message,
|
||||||
height: context.lowValue,
|
isSquare: true,
|
||||||
),
|
),
|
||||||
Indicator(
|
SizedBox(
|
||||||
color: Colors.green,
|
height: context.lowValue,
|
||||||
text: appLocalization(context).active_devices_message,
|
),
|
||||||
isSquare: true,
|
],
|
||||||
),
|
),
|
||||||
SizedBox(
|
if (normalCount != 0)
|
||||||
height: context.lowValue,
|
Column(
|
||||||
),
|
children: [
|
||||||
Indicator(
|
Indicator(
|
||||||
color: Colors.red,
|
color: Colors.green,
|
||||||
text: appLocalization(context).warning_devices_message,
|
text: appLocalization(context).active_devices_message,
|
||||||
isSquare: true,
|
isSquare: true,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: context.lowValue,
|
height: context.lowValue,
|
||||||
),
|
),
|
||||||
Indicator(
|
],
|
||||||
color: Colors.yellow,
|
),
|
||||||
text: appLocalization(context).in_progress_message,
|
if (warningCount != 0)
|
||||||
isSquare: true,
|
Column(
|
||||||
),
|
children: [
|
||||||
SizedBox(
|
Indicator(
|
||||||
height: context.lowValue,
|
color: Colors.red,
|
||||||
),
|
text: appLocalization(context).warning_devices_message,
|
||||||
Indicator(
|
isSquare: true,
|
||||||
color: Colors.black,
|
),
|
||||||
text: appLocalization(context).error_message_uppercase,
|
SizedBox(
|
||||||
isSquare: true,
|
height: context.lowValue,
|
||||||
),
|
),
|
||||||
// const SizedBox(
|
],
|
||||||
// height: 18,
|
),
|
||||||
// ),
|
if (inProgressCount != 0)
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Indicator(
|
||||||
|
color: Colors.yellow,
|
||||||
|
text: appLocalization(context).in_progress_message,
|
||||||
|
isSquare: true,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: context.lowValue,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (errorCount != 0)
|
||||||
|
Indicator(
|
||||||
|
color: Colors.black,
|
||||||
|
text: appLocalization(context).error_message_uppercase,
|
||||||
|
isSquare: true,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateDevicesOnTapPieChart(int touchedIndex) {
|
||||||
|
log("Update PieChart On Tap Function");
|
||||||
|
if (touchedIndex == 0) {
|
||||||
|
devicesManagerBloc.getDeviceByState(-1);
|
||||||
|
} else if (touchedIndex == 1) {
|
||||||
|
devicesManagerBloc.getDeviceByState(0);
|
||||||
|
} else if (touchedIndex == 2) {
|
||||||
|
devicesManagerBloc.getDeviceByState(1);
|
||||||
|
} else if (touchedIndex == 3) {
|
||||||
|
devicesManagerBloc.getDeviceByState(2);
|
||||||
|
} else {
|
||||||
|
devicesManagerBloc.getDeviceByState(-2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Indicator extends StatelessWidget {
|
class Indicator extends StatelessWidget {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class AppThemeDark extends AppTheme {
|
|||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
scheme: FlexScheme.flutterDash,
|
scheme: FlexScheme.flutterDash,
|
||||||
subThemesData: const FlexSubThemesData(
|
subThemesData: const FlexSubThemesData(
|
||||||
|
snackBarBackgroundSchemeColor: SchemeColor.black,
|
||||||
inputDecoratorRadius: 30,
|
inputDecoratorRadius: 30,
|
||||||
interactionEffects: true,
|
interactionEffects: true,
|
||||||
tintedDisabledControls: true,
|
tintedDisabledControls: true,
|
||||||
@@ -30,24 +31,4 @@ class AppThemeDark extends AppTheme {
|
|||||||
),
|
),
|
||||||
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
visualDensity: FlexColorScheme.comfortablePlatformDensity,
|
||||||
);
|
);
|
||||||
|
|
||||||
// ThemeData.dark().copyWith(
|
|
||||||
// useMaterial3: true,
|
|
||||||
// colorScheme: _buildColorScheme,
|
|
||||||
// );
|
|
||||||
|
|
||||||
// ColorScheme get _buildColorScheme => FlexColorScheme.dark().toScheme;
|
|
||||||
// ColorScheme(
|
|
||||||
// brightness: Brightness.dark,
|
|
||||||
// primary: Colors.blue.shade900,
|
|
||||||
// onPrimary: Colors.blue,
|
|
||||||
// secondary: Colors.white,
|
|
||||||
// onSecondary: Colors.white70,
|
|
||||||
// error: Colors.red,
|
|
||||||
// onError: Colors.orange,
|
|
||||||
// background: Colors.black,
|
|
||||||
// onBackground: Colors.white70,
|
|
||||||
// surface: Colors.grey,
|
|
||||||
// onSurface: Colors.white,
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class AppThemeLight extends AppTheme {
|
|||||||
scheme: FlexScheme.flutterDash,
|
scheme: FlexScheme.flutterDash,
|
||||||
bottomAppBarElevation: 20.0,
|
bottomAppBarElevation: 20.0,
|
||||||
subThemesData: const FlexSubThemesData(
|
subThemesData: const FlexSubThemesData(
|
||||||
|
snackBarBackgroundSchemeColor: SchemeColor.surfaceBright,
|
||||||
inputDecoratorRadius: 30,
|
inputDecoratorRadius: 30,
|
||||||
interactionEffects: true,
|
interactionEffects: true,
|
||||||
tintedDisabledControls: true,
|
tintedDisabledControls: true,
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class DeviceUtils {
|
|||||||
message = appLocalization(context).in_progress_message;
|
message = appLocalization(context).in_progress_message;
|
||||||
} else if (state == 3) {
|
} else if (state == 3) {
|
||||||
message = appLocalization(context).in_progress_message;
|
message = appLocalization(context).in_progress_message;
|
||||||
}
|
} else if (state == -2) {}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +144,10 @@ class DeviceUtils {
|
|||||||
return sortedDevices;
|
return sortedDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Device> sortDeviceAZByName(List<Device> devices) {
|
||||||
|
return devices..sort((a, b) => (a.name ?? '').compareTo(b.name ?? ''));
|
||||||
|
}
|
||||||
|
|
||||||
Color getTableRowColor(int state) {
|
Color getTableRowColor(int state) {
|
||||||
if (state == 1) {
|
if (state == 1) {
|
||||||
return Colors.red;
|
return Colors.red;
|
||||||
@@ -251,12 +255,14 @@ class DeviceUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IconData getSignalIcon(BuildContext context, String signal) {
|
IconData getSignalIcon(BuildContext context, String signal) {
|
||||||
if (signal == appLocalization(context).gf_weak_signal_message) {
|
if (signal == appLocalization(context).low_message_uppercase) {
|
||||||
return Icons.signal_cellular_alt_1_bar;
|
return Icons.signal_cellular_alt_1_bar;
|
||||||
} else if (signal == appLocalization(context).gf_moderate_signal_message) {
|
} else if (signal == appLocalization(context).moderate_message_uppercase) {
|
||||||
return Icons.signal_cellular_alt_2_bar;
|
return Icons.signal_cellular_alt_2_bar;
|
||||||
} else {
|
} else if (signal == appLocalization(context).good_message_uppercase) {
|
||||||
return Icons.signal_cellular_alt;
|
return Icons.signal_cellular_alt;
|
||||||
|
} else {
|
||||||
|
return Icons.signal_cellular_connected_no_internet_4_bar_rounded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,12 +318,12 @@ class DeviceUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color getSignalIconColor(BuildContext context, String signal) {
|
Color getSignalIconColor(BuildContext context, String signal) {
|
||||||
if (signal == appLocalization(context).gf_weak_signal_message) {
|
if (signal == appLocalization(context).good_message_uppercase) {
|
||||||
return Colors.red;
|
|
||||||
} else if (signal == appLocalization(context).gf_moderate_signal_message) {
|
|
||||||
return Colors.yellow;
|
|
||||||
} else {
|
|
||||||
return Colors.green;
|
return Colors.green;
|
||||||
|
} else if (signal == appLocalization(context).moderate_message_uppercase) {
|
||||||
|
return Colors.orangeAccent;
|
||||||
|
} else {
|
||||||
|
return Colors.red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user