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.
cloudsolutions-atoms/lib/views/widgets/parts/part_item.dart

91 lines
2.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:test_sa/models/part.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
class PartItem extends StatefulWidget {
final Part part;
final Function(Part) onDelete;
const PartItem({Key key, this.part, this.onDelete}) : super(key: key);
@override
_PartItemState createState() => _PartItemState();
}
class _PartItemState extends State<PartItem> {
@override
Widget build(BuildContext context) {
//final _subtitle = AppLocalization.of(context).subtitle;
return Column(
children: [
Divider(),
Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(widget.part.code,
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 12,
fontWeight: FontWeight.bold
),
),
),
AIconButton2(
iconData: Icons.add,
color: Theme.of(context).primaryColor,
onPressed: (){
widget.part.quantity++;
setState(() {});
},
),
AIconButton2(
iconData: Icons.remove,
color: Theme.of(context).primaryColor,
onPressed: widget.part.quantity < 2 ? null : (){
widget.part.quantity--;
setState(() {});
},
),
SizedBox(width: 8*AppStyle.getScaleFactor(context),),
Text(widget.part.quantity.toString(),
style: Theme.of(context).textTheme.headline6.copyWith(
//fontSize: 12,
//fontWeight: FontWeight.bold
),
),
SizedBox(width: 8*AppStyle.getScaleFactor(context),),
],
),
widget.part.name == null ? SizedBox.shrink() :
Text(widget.part.name,
style: Theme.of(context).textTheme.caption.copyWith(
fontSize: 11,
fontWeight: FontWeight.bold
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
)),
AIconButton2(
iconData: Icons.close,
color: Colors.red,
onPressed: (){
widget.onDelete(widget.part);
},
),
],
),
],
);
}
}