You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
Dart
45 lines
1.3 KiB
Dart
|
3 years ago
|
import 'package:test_sa/models/visits/visit.dart';
|
||
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
||
|
|
import 'package:test_sa/views/app_style/sizing.dart';
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
class VisitStatusLabel extends StatelessWidget {
|
||
|
|
final Visit visit;
|
||
|
|
|
||
|
|
const VisitStatusLabel({Key key, this.visit}) : super(key: key);
|
||
|
|
|
||
|
|
Color getStatusColor(){
|
||
|
|
switch(visit.status.id){
|
||
|
|
case 0: return AColors.green;
|
||
|
|
case 1: return AColors.grey;
|
||
|
|
case 2: return AColors.grey;
|
||
|
|
default : return AColors.grey;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Container(
|
||
|
|
padding: EdgeInsets.symmetric(vertical: 2,horizontal: 8),
|
||
|
|
alignment: Alignment.center,
|
||
|
|
decoration: BoxDecoration(
|
||
|
|
color: getStatusColor(),
|
||
|
|
borderRadius: BorderRadius.circular(
|
||
|
|
AppStyle.getBorderRadius(context)
|
||
|
|
),
|
||
|
|
boxShadow: [
|
||
|
|
AppStyle.boxShadow
|
||
|
|
]
|
||
|
|
),
|
||
|
|
child: Text(
|
||
|
|
visit.status.label == null
|
||
|
|
|| visit.status.label.isEmpty
|
||
|
|
? "no status" :visit.status.label,
|
||
|
|
style: Theme.of(context).textTheme.subtitle2.copyWith(
|
||
|
|
color: getStatusColor().computeLuminance() > 0.5
|
||
|
|
? AColors.black : Colors.white,
|
||
|
|
),
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|