Update Bottom Navigator in MainScreen
This commit is contained in:
@@ -61,203 +61,207 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: context.paddingLow,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
appLocalization(context).notification,
|
||||
style: context.titleMediumTextStyle,
|
||||
),
|
||||
SizedBox(width: context.lowValue),
|
||||
StreamBuilder<int>(
|
||||
stream: homeBloc.streamCountNotitication,
|
||||
builder: (context, countSnapshot) {
|
||||
return Text(
|
||||
"(${countSnapshot.data ?? 0})",
|
||||
style: context.titleMediumTextStyle,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: StreamBuilder<Map<String, List<DeviceWithAlias>>>(
|
||||
stream: homeBloc.streamOwnerDevicesStatus,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.data?['state'] != null ||
|
||||
snapshot.data?['battery'] != null) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (snapshot.data?['state'] != null)
|
||||
...snapshot.data!['state']!
|
||||
.map(
|
||||
(item) => FutureBuilder<Widget>(
|
||||
future: warningCard(
|
||||
context, apiServices, item),
|
||||
builder: (context, warningCardSnapshot) {
|
||||
if (warningCardSnapshot.hasData) {
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 400,
|
||||
maxHeight: 260,
|
||||
),
|
||||
child: warningCardSnapshot.data!,
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
if (snapshot.data?['battery'] != null)
|
||||
...snapshot.data!['battery']!
|
||||
.map(
|
||||
(batteryItem) => FutureBuilder<Widget>(
|
||||
future: notificationCard(
|
||||
context,
|
||||
"lowBattery",
|
||||
"Cảnh báo pin yếu",
|
||||
batteryItem.name!,
|
||||
batteryItem.areaPath!,
|
||||
),
|
||||
builder: (context, warningCardSnapshot) {
|
||||
if (warningCardSnapshot.hasData) {
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 400,
|
||||
maxHeight: 260,
|
||||
),
|
||||
child: warningCardSnapshot.data!,
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
]);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: context.paddingMedium,
|
||||
child: Center(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: 40,
|
||||
color: Colors.green,
|
||||
),
|
||||
SizedBox(width: context.lowValue),
|
||||
Text(
|
||||
appLocalization(context)
|
||||
.notification_description,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: true,
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: context.paddingLow,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
appLocalization(context).notification,
|
||||
style: context.titleMediumTextStyle,
|
||||
),
|
||||
SizedBox(width: context.lowValue),
|
||||
StreamBuilder<int>(
|
||||
stream: homeBloc.streamCountNotitication,
|
||||
builder: (context, countSnapshot) {
|
||||
return Text(
|
||||
"(${countSnapshot.data ?? 0})",
|
||||
style: context.titleMediumTextStyle,
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: StreamBuilder<Map<String, List<DeviceWithAlias>>>(
|
||||
stream: homeBloc.streamOwnerDevicesStatus,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.data?['state'] != null ||
|
||||
snapshot.data?['battery'] != null) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (snapshot.data?['state'] != null)
|
||||
...snapshot.data!['state']!
|
||||
.map(
|
||||
(item) => FutureBuilder<Widget>(
|
||||
future: warningCard(
|
||||
context, apiServices, item),
|
||||
builder:
|
||||
(context, warningCardSnapshot) {
|
||||
if (warningCardSnapshot.hasData) {
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 400,
|
||||
maxHeight: 260,
|
||||
),
|
||||
child: warningCardSnapshot.data!,
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
if (snapshot.data?['battery'] != null)
|
||||
...snapshot.data!['battery']!
|
||||
.map(
|
||||
(batteryItem) => FutureBuilder<Widget>(
|
||||
future: notificationCard(
|
||||
context,
|
||||
"lowBattery",
|
||||
"Cảnh báo pin yếu",
|
||||
batteryItem.name!,
|
||||
batteryItem.areaPath!,
|
||||
),
|
||||
builder:
|
||||
(context, warningCardSnapshot) {
|
||||
if (warningCardSnapshot.hasData) {
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 400,
|
||||
maxHeight: 260,
|
||||
),
|
||||
child: warningCardSnapshot.data!,
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
]);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: context.paddingMedium,
|
||||
child: Center(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.check_circle_outline_rounded,
|
||||
size: 40,
|
||||
color: Colors.green,
|
||||
),
|
||||
SizedBox(width: context.lowValue),
|
||||
Text(
|
||||
appLocalization(context)
|
||||
.notification_description,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: true,
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamAllDevicesAlias,
|
||||
initialData: allDevicesAlias,
|
||||
builder: (context, allDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOnlineDevicesAlias,
|
||||
initialData: onlineDevicesAlias,
|
||||
builder: (context, onlineDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOfflineDevicesAlias,
|
||||
initialData: offlineDevicesAlias,
|
||||
builder: (context, deviceDashboardSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamWarningDevicesAlias,
|
||||
initialData: warningDevicesAlias,
|
||||
builder: (context, warningDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamNotUseDevicesAlias,
|
||||
initialData: notUseDevicesAlias,
|
||||
builder: (context, notUseSnapshot) {
|
||||
return OverviewCard(
|
||||
isOwner: true,
|
||||
total: allDeviceSnapshot.data!.length,
|
||||
active: onlineDeviceSnapshot.data!.length,
|
||||
inactive:
|
||||
deviceDashboardSnapshot.data!.length,
|
||||
warning: warningDeviceSnapshot.data!.length,
|
||||
unused: notUseSnapshot.data!.length,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: context.lowValue),
|
||||
StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamAllDevicesAliasJoined,
|
||||
initialData: allDevicesAliasJoined,
|
||||
builder: (context, allDeviceSnapshot) {
|
||||
if (allDeviceSnapshot.data?.isEmpty ?? true) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOnlineDevicesAliasJoined,
|
||||
initialData: onlineDevicesAliasJoined,
|
||||
builder: (context, onlineDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOfflineDevicesAliasJoined,
|
||||
initialData: offlineDevicesAliasJoined,
|
||||
builder: (context, deviceDashboardSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamWarningDevicesAliasJoined,
|
||||
initialData: warningDevicesAliasJoined,
|
||||
builder: (context, warningDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamNotUseDevicesAliasJoined,
|
||||
initialData: notUseDevicesAliasJoined,
|
||||
builder: (context, notUseSnapshot) {
|
||||
return OverviewCard(
|
||||
isOwner: false,
|
||||
total: allDeviceSnapshot.data!.length,
|
||||
active: onlineDeviceSnapshot.data!.length,
|
||||
inactive:
|
||||
deviceDashboardSnapshot.data!.length,
|
||||
warning: warningDeviceSnapshot.data!.length,
|
||||
unused: notUseSnapshot.data!.length,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamAllDevicesAlias,
|
||||
initialData: allDevicesAlias,
|
||||
builder: (context, allDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOnlineDevicesAlias,
|
||||
initialData: onlineDevicesAlias,
|
||||
builder: (context, onlineDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOfflineDevicesAlias,
|
||||
initialData: offlineDevicesAlias,
|
||||
builder: (context, deviceDashboardSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamWarningDevicesAlias,
|
||||
initialData: warningDevicesAlias,
|
||||
builder: (context, warningDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamNotUseDevicesAlias,
|
||||
initialData: notUseDevicesAlias,
|
||||
builder: (context, notUseSnapshot) {
|
||||
return OverviewCard(
|
||||
isOwner: true,
|
||||
total: allDeviceSnapshot.data!.length,
|
||||
active: onlineDeviceSnapshot.data!.length,
|
||||
inactive:
|
||||
deviceDashboardSnapshot.data!.length,
|
||||
warning: warningDeviceSnapshot.data!.length,
|
||||
unused: notUseSnapshot.data!.length,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(height: context.lowValue),
|
||||
StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamAllDevicesAliasJoined,
|
||||
initialData: allDevicesAliasJoined,
|
||||
builder: (context, allDeviceSnapshot) {
|
||||
if (allDeviceSnapshot.data?.isEmpty ?? true) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOnlineDevicesAliasJoined,
|
||||
initialData: onlineDevicesAliasJoined,
|
||||
builder: (context, onlineDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamOfflineDevicesAliasJoined,
|
||||
initialData: offlineDevicesAliasJoined,
|
||||
builder: (context, deviceDashboardSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamWarningDevicesAliasJoined,
|
||||
initialData: warningDevicesAliasJoined,
|
||||
builder: (context, warningDeviceSnapshot) {
|
||||
return StreamBuilder<List<DeviceWithAlias>>(
|
||||
stream: homeBloc.streamNotUseDevicesAliasJoined,
|
||||
initialData: notUseDevicesAliasJoined,
|
||||
builder: (context, notUseSnapshot) {
|
||||
return OverviewCard(
|
||||
isOwner: false,
|
||||
total: allDeviceSnapshot.data!.length,
|
||||
active: onlineDeviceSnapshot.data!.length,
|
||||
inactive:
|
||||
deviceDashboardSnapshot.data!.length,
|
||||
warning: warningDeviceSnapshot.data!.length,
|
||||
unused: notUseSnapshot.data!.length,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user