Add drone logo + change color off battery + drone + flight logo
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rtime/models/battery.dart';
|
||||
import 'package:rtime/images_manager.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:rtime/providers/color_provider.dart';
|
||||
|
||||
class BatteryCard extends StatelessWidget {
|
||||
final Battery battery;
|
||||
@ -14,10 +17,13 @@ class BatteryCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final BorderRadius cardBorderRadius =
|
||||
Theme.of(context).cardTheme.shape is RoundedRectangleBorder
|
||||
? (Theme.of(context).cardTheme.shape as RoundedRectangleBorder).borderRadius as BorderRadius
|
||||
: BorderRadius.circular(12);
|
||||
final colorProvider = Provider.of<ColorProvider>(context);
|
||||
final accentColor = colorProvider.accentColor;
|
||||
|
||||
final ShapeBorder? cardShape = Theme.of(context).cardTheme.shape;
|
||||
final BorderRadius cardBorderRadius = (cardShape is RoundedRectangleBorder)
|
||||
? (cardShape).borderRadius as BorderRadius
|
||||
: BorderRadius.circular(12);
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(right: 16),
|
||||
@ -34,23 +40,21 @@ class BatteryCard extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
SizedBox(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.blueGrey[700]
|
||||
: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: battery.imageUuid != null && battery.imageUuid!.isNotEmpty
|
||||
? FutureBuilder<Image?>(
|
||||
future: ImagesManager.instance.loadImage(battery.imageUuid!),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator(color: Colors.tealAccent));
|
||||
return Center(child: CircularProgressIndicator(color: accentColor));
|
||||
} else if (snapshot.hasError || !snapshot.hasData || snapshot.data == null) {
|
||||
return Icon(Icons.broken_image, size: 50, color: Colors.blueGrey[400]);
|
||||
return Icon(
|
||||
Icons.battery_charging_full,
|
||||
size: 80,
|
||||
color: accentColor,
|
||||
);
|
||||
} else {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@ -59,7 +63,11 @@ class BatteryCard extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
)
|
||||
: Icon(Icons.battery_charging_full, size: 50, color: Theme.of(context).brightness == Brightness.dark ? Colors.tealAccent : Colors.green.shade400),
|
||||
: Icon(
|
||||
Icons.battery_charging_full,
|
||||
size: 80,
|
||||
color: accentColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rtime/models/drone.dart';
|
||||
import 'package:rtime/images_manager.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:rtime/providers/color_provider.dart';
|
||||
|
||||
class DroneCard extends StatelessWidget {
|
||||
final Drone drone;
|
||||
@ -14,6 +17,8 @@ class DroneCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorProvider = Provider.of<ColorProvider>(context);
|
||||
final accentColor = colorProvider.accentColor;
|
||||
|
||||
final BorderRadius cardBorderRadius =
|
||||
Theme.of(context).cardTheme.shape is RoundedRectangleBorder
|
||||
@ -22,10 +27,8 @@ class DroneCard extends StatelessWidget {
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(right: 16),
|
||||
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
|
||||
borderRadius: cardBorderRadius,
|
||||
child: ClipRRect(
|
||||
borderRadius: cardBorderRadius,
|
||||
@ -36,23 +39,22 @@ class DroneCard extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
SizedBox(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.blueGrey[700]
|
||||
: Colors.grey[200],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: drone.imageUuid != null && drone.imageUuid!.isNotEmpty
|
||||
? FutureBuilder<Image?>(
|
||||
future: ImagesManager.instance.loadImage(drone.imageUuid!),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator(color: Colors.lightBlueAccent));
|
||||
return Center(child: CircularProgressIndicator(color: accentColor));
|
||||
} else if (snapshot.hasError || !snapshot.hasData || snapshot.data == null) {
|
||||
return Icon(Icons.broken_image, size: 50, color: Colors.blueGrey[400]);
|
||||
return SvgPicture.asset(
|
||||
'assets/images/drone.svg',
|
||||
width: 50,
|
||||
height: 50,
|
||||
colorFilter: ColorFilter.mode(accentColor, BlendMode.srcIn),
|
||||
);
|
||||
} else {
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
@ -61,7 +63,12 @@ class DroneCard extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
)
|
||||
: Icon(Icons.airplanemode_active, size: 50, color: Theme.of(context).brightness == Brightness.dark ? Colors.lightBlueAccent : Colors.blue.shade400),
|
||||
: SvgPicture.asset(
|
||||
'assets/images/drone.svg',
|
||||
width: 50,
|
||||
height: 50,
|
||||
colorFilter: ColorFilter.mode(accentColor, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user