2020-10-13 18:38:00 +06:30
|
|
|
import 'package:fcs/domain/entities/discount.dart';
|
|
|
|
|
import 'package:fcs/helpers/theme.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'local_text.dart';
|
|
|
|
|
|
|
|
|
|
class DiscountDropdown<T> extends StatelessWidget {
|
2021-09-10 14:25:37 +06:30
|
|
|
final Function(T)? callback;
|
|
|
|
|
final IconData? iconData;
|
|
|
|
|
final T? selectedValue;
|
|
|
|
|
final List<T>? values;
|
2020-10-13 18:38:00 +06:30
|
|
|
|
|
|
|
|
const DiscountDropdown(
|
2021-09-10 14:25:37 +06:30
|
|
|
{Key? key, this.callback, this.iconData, this.selectedValue, this.values})
|
2020-10-13 18:38:00 +06:30
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 5.0, right: 0),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 0, right: 10),
|
|
|
|
|
child: Icon(iconData, color: primaryColor),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 18.0),
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
"invoice.discount",
|
|
|
|
|
color: Colors.black54,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
DropdownButton<T>(
|
|
|
|
|
isDense: true,
|
|
|
|
|
value: selectedValue,
|
|
|
|
|
style: TextStyle(color: Colors.black, fontSize: 14),
|
|
|
|
|
underline: Container(
|
|
|
|
|
height: 1,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
),
|
2021-09-10 14:25:37 +06:30
|
|
|
onChanged: (T? newValue) {
|
|
|
|
|
callback!(newValue!);
|
2020-10-13 18:38:00 +06:30
|
|
|
},
|
|
|
|
|
isExpanded: true,
|
2021-09-10 14:25:37 +06:30
|
|
|
items: values!.map<DropdownMenuItem<T>>((T value) {
|
2020-10-13 18:38:00 +06:30
|
|
|
return DropdownMenuItem<T>(
|
|
|
|
|
value: value,
|
2021-09-10 15:22:11 +06:30
|
|
|
child: Text(
|
|
|
|
|
value == null ? "" : (value as Discount).code!,
|
2020-10-13 18:38:00 +06:30
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(color: primaryColor)),
|
|
|
|
|
);
|
|
|
|
|
}).toList(),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|