2019-08-24 20:39:25 +03:00
|
|
|
part of '../../main.dart';
|
|
|
|
|
|
|
|
class ProductPurchase extends StatelessWidget {
|
|
|
|
|
|
|
|
final ProductDetails product;
|
|
|
|
final onBuy;
|
|
|
|
final purchased;
|
|
|
|
|
|
|
|
const ProductPurchase({Key key, @required this.product, @required this.onBuy, this.purchased}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-08-30 15:04:51 +03:00
|
|
|
String period = "";
|
2019-08-24 20:39:25 +03:00
|
|
|
Color priceColor;
|
2019-08-30 15:04:51 +03:00
|
|
|
String buttonText = '';
|
|
|
|
String buttonTextInactive = '';
|
2019-08-26 19:42:26 +03:00
|
|
|
if (product.id.contains("year")) {
|
2019-08-30 15:04:51 +03:00
|
|
|
period += "/ year";
|
|
|
|
buttonText = "Subscribe";
|
|
|
|
buttonTextInactive = "Already";
|
2019-08-24 20:39:25 +03:00
|
|
|
priceColor = Colors.amber;
|
2019-08-26 19:42:26 +03:00
|
|
|
} else {
|
2019-08-30 15:04:51 +03:00
|
|
|
period += "";
|
|
|
|
buttonText = "Pay";
|
|
|
|
buttonTextInactive = "Paid";
|
2019-08-26 19:42:26 +03:00
|
|
|
priceColor = Colors.deepOrangeAccent;
|
2019-08-24 20:39:25 +03:00
|
|
|
}
|
|
|
|
return Card(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.all(Sizes.leftWidgetPadding),
|
|
|
|
child: Flex(
|
|
|
|
direction: Axis.horizontal,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
flex: 5,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(right: Sizes.rightWidgetPadding),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
"${product.title}",
|
2020-04-04 18:13:55 +03:00
|
|
|
style: Theme.of(context).textTheme.body2,
|
2019-08-24 20:39:25 +03:00
|
|
|
),
|
|
|
|
Container(height: Sizes.rowPadding,),
|
|
|
|
Text(
|
|
|
|
"${product.description}",
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 4,
|
|
|
|
softWrap: true,
|
|
|
|
),
|
|
|
|
Container(height: Sizes.rowPadding,),
|
2020-04-04 18:13:55 +03:00
|
|
|
Text("${product.price} $period", style: Theme.of(context).textTheme.body1.copyWith(
|
|
|
|
color: priceColor
|
|
|
|
)),
|
2019-08-24 20:39:25 +03:00
|
|
|
],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: RaisedButton(
|
2020-04-04 18:13:55 +03:00
|
|
|
child: Text(this.purchased ? buttonTextInactive : buttonText, style: Theme.of(context).textTheme.button),
|
2019-08-24 20:39:25 +03:00
|
|
|
color: Colors.blue,
|
|
|
|
onPressed: this.purchased ? null : () => this.onBuy(this.product),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|