chore(ui): Update notificationCard and warningCard in HomeScreen

This commit is contained in:
anhtunz
2025-04-14 11:30:10 +07:00
parent 345c554519
commit 758cc22a0f
2 changed files with 33 additions and 32 deletions

View File

@@ -82,60 +82,57 @@ class _HomeScreenState extends State<HomeScreen> {
stream: homeBloc.streamOwnerDevicesStatus, stream: homeBloc.streamOwnerDevicesStatus,
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.data?['state'] != null || snapshot.data?['battery'] != null) { if (snapshot.data?['state'] != null || snapshot.data?['battery'] != null) {
return Row( return ConstrainedBox(
constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width),
child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (snapshot.data?['state'] != null) if (snapshot.data?['state'] != null)
...snapshot.data!['state']! ...snapshot.data!['state']!
.map( .map(
(item) => FutureBuilder<Widget>( (item) => SizedBox(
width: context.dynamicWidth(0.95),
child: FutureBuilder<Widget>(
future: warningCard(context, apiServices, item), future: warningCard(context, apiServices, item),
builder: (context, warningCardSnapshot) { builder: (context, warningCardSnapshot) {
if (warningCardSnapshot.hasData) { if (warningCardSnapshot.hasData) {
return ConstrainedBox( return warningCardSnapshot.data!;
constraints: const BoxConstraints(
maxWidth: 400,
maxHeight: 260,
),
child: warningCardSnapshot.data!,
);
} else { } else {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
}, },
), ),
),
) )
.toList(), .toList(),
if (snapshot.data?['battery'] != null) if (snapshot.data?['battery'] != null)
...snapshot.data!['battery']! ...snapshot.data!['battery']!
.map( .map(
(batteryItem) => FutureBuilder<Widget>( (batteryItem) => SizedBox(
width: context.dynamicWidth(0.95),
child: FutureBuilder<Widget>(
future: notificationCard( future: notificationCard(
context, "lowBattery", appLocalization(context).low_battery_message, batteryItem), context, "lowBattery", appLocalization(context).low_battery_message, batteryItem),
builder: (context, warningCardSnapshot) { builder: (context, warningCardSnapshot) {
if (warningCardSnapshot.hasData) { if (warningCardSnapshot.hasData) {
return ConstrainedBox( return warningCardSnapshot.data!;
constraints: const BoxConstraints(
maxWidth: 400,
maxHeight: 260,
),
child: warningCardSnapshot.data!,
);
} else { } else {
return const SizedBox.shrink(); return const SizedBox.shrink();
} }
}, },
), ),
),
) )
.toList(), .toList(),
], ],
),
); );
} else { } else {
return Padding( return Padding(
padding: context.paddingMedium, padding: context.paddingMedium,
child: Center( child: Center(
child: Row( child: Row(
mainAxisSize: MainAxisSize.min,
children: [ children: [
const Icon( const Icon(
Icons.check_circle_outline_rounded, Icons.check_circle_outline_rounded,
@@ -159,6 +156,11 @@ class _HomeScreenState extends State<HomeScreen> {
), ),
), ),
), ),
StreamBuilder<Map<String, List<DeviceWithAlias>>>( StreamBuilder<Map<String, List<DeviceWithAlias>>>(
stream: homeBloc.streamAllDevicesAliasMap, stream: homeBloc.streamAllDevicesAliasMap,
builder: (context, allDevicesAliasMapSnapshot) { builder: (context, allDevicesAliasMapSnapshot) {

View File

@@ -23,7 +23,6 @@ class OverviewCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Card(
margin: context.paddingLow,
elevation: 8, elevation: 8,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
child: Padding( child: Padding(