2022-08-04 17:52:06 +03:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:info_tren/pages/train_info_page/train_info_constants.dart';
|
|
|
|
import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart';
|
|
|
|
|
|
|
|
class MaterialBadge extends StatelessWidget {
|
|
|
|
final String text;
|
|
|
|
final String caption;
|
|
|
|
final bool isNotScheduled;
|
|
|
|
final bool isOnTime;
|
|
|
|
final bool isDelayed;
|
|
|
|
|
2022-10-31 01:25:45 +01:00
|
|
|
const MaterialBadge({
|
2022-08-04 17:52:06 +03:00
|
|
|
required this.text,
|
|
|
|
required this.caption,
|
|
|
|
this.isNotScheduled = false,
|
|
|
|
this.isOnTime = false,
|
|
|
|
this.isDelayed = false,
|
2022-10-31 01:49:11 +01:00
|
|
|
super.key,
|
2022-08-04 17:52:06 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Color foregroundColor = Colors.white70;
|
|
|
|
Color? backgroundColor;
|
|
|
|
|
|
|
|
if (isNotScheduled) {
|
|
|
|
foregroundColor = Colors.orange.shade300;
|
|
|
|
backgroundColor = Colors.orange.shade900.withOpacity(0.3);
|
|
|
|
}
|
|
|
|
else if (isOnTime) {
|
|
|
|
foregroundColor = Colors.green.shade300;
|
|
|
|
backgroundColor = Colors.green.shade900.withOpacity(0.3);
|
|
|
|
}
|
|
|
|
else if (isDelayed) {
|
|
|
|
foregroundColor = Colors.red.shade300;
|
|
|
|
backgroundColor = Colors.red.shade900.withOpacity(0.3);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
border: Border.all(
|
|
|
|
width: 2,
|
|
|
|
color: foregroundColor,
|
|
|
|
),
|
|
|
|
color: backgroundColor,
|
|
|
|
),
|
|
|
|
width: isSmallScreen(context) ? 42 : 48,
|
|
|
|
height: isSmallScreen(context) ? 42 : 48,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
text,
|
2022-10-31 01:30:29 +01:00
|
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
2022-08-04 17:52:06 +03:00
|
|
|
fontSize: isSmallScreen(context) ? 16 : 20,
|
|
|
|
fontWeight: MediaQuery.of(context).boldText ? FontWeight.w400 : FontWeight.w200,
|
|
|
|
color: MediaQuery.of(context).boldText ? Colors.white70 : foregroundColor,
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
caption,
|
2022-10-31 01:30:29 +01:00
|
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
2022-08-04 17:52:06 +03:00
|
|
|
fontSize: 10,
|
|
|
|
color: MediaQuery.of(context).boldText ? Colors.white70 : foregroundColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class CupertinoBadge extends StatelessWidget {
|
|
|
|
final String text;
|
|
|
|
final String caption;
|
|
|
|
final bool isNotScheduled;
|
|
|
|
final bool isOnTime;
|
|
|
|
final bool isDelayed;
|
|
|
|
|
2022-10-31 01:30:29 +01:00
|
|
|
const CupertinoBadge({
|
2022-08-04 17:52:06 +03:00
|
|
|
required this.text,
|
|
|
|
required this.caption,
|
|
|
|
this.isNotScheduled = false,
|
|
|
|
this.isOnTime = false,
|
|
|
|
this.isDelayed = false,
|
2022-10-31 01:49:11 +01:00
|
|
|
super.key,
|
2022-08-04 17:52:06 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-31 01:49:11 +01:00
|
|
|
Color foregroundColor = foregroundWhite;
|
2022-08-04 17:52:06 +03:00
|
|
|
Color? backgroundColor;
|
|
|
|
|
|
|
|
if (isNotScheduled) {
|
2022-10-31 01:30:29 +01:00
|
|
|
foregroundColor = const Color.fromRGBO(225, 175, 30, 1);
|
|
|
|
backgroundColor = const Color.fromRGBO(80, 40, 10, 1);
|
2022-08-04 17:52:06 +03:00
|
|
|
}
|
|
|
|
else if (isOnTime) {
|
2022-10-31 01:30:29 +01:00
|
|
|
foregroundColor = const Color.fromRGBO(130, 175, 65, 1);
|
|
|
|
backgroundColor = const Color.fromRGBO(40, 80, 10, 1);
|
2022-08-04 17:52:06 +03:00
|
|
|
}
|
|
|
|
else if (isDelayed) {
|
2022-10-31 01:30:29 +01:00
|
|
|
foregroundColor = const Color.fromRGBO(225, 75, 30, 1);
|
|
|
|
backgroundColor = const Color.fromRGBO(80, 20, 10, 1);
|
2022-08-04 17:52:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
border: Border.all(
|
|
|
|
width: 2,
|
|
|
|
color: foregroundColor,
|
|
|
|
),
|
|
|
|
color: backgroundColor,
|
|
|
|
// color: CupertinoColors.activeOrange,
|
|
|
|
),
|
|
|
|
width: 48,
|
|
|
|
height: 48,
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
text,
|
|
|
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: MediaQuery.of(context).boldText ? FontWeight.w400 : FontWeight.w200,
|
2022-10-31 01:49:11 +01:00
|
|
|
color: MediaQuery.of(context).boldText ? foregroundWhite : foregroundColor,
|
2022-08-04 17:52:06 +03:00
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
caption,
|
|
|
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
|
|
fontSize: 12,
|
2022-10-31 01:49:11 +01:00
|
|
|
color: MediaQuery.of(context).boldText ? foregroundWhite : foregroundColor,
|
2022-08-04 17:52:06 +03:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|