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}",
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 16.0
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(height: Sizes.rowPadding,),
|
|
|
|
Text(
|
|
|
|
"${product.description}",
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 4,
|
|
|
|
softWrap: true,
|
|
|
|
),
|
|
|
|
Container(height: Sizes.rowPadding,),
|
|
|
|
Text("${product.price} $period", style: TextStyle(color: priceColor)),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 2,
|
|
|
|
child: RaisedButton(
|
2019-08-30 15:04:51 +03:00
|
|
|
child: Text(this.purchased ? buttonTextInactive : buttonText, style: TextStyle(color: Colors.white)),
|
2019-08-24 20:39:25 +03:00
|
|
|
color: Colors.blue,
|
|
|
|
onPressed: this.purchased ? null : () => this.onBuy(this.product),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|