First Iteration of Yearly Purchase

This commit is contained in:
Vishesh Handa
2020-08-20 09:32:40 +02:00
parent 9db302164e
commit 518ae9d4ef
3 changed files with 111 additions and 42 deletions

View File

@ -241,7 +241,5 @@ purchase_screen:
desc: 'GitJournal is completely open source and is the result of significant development work. It has no venture capital or corporation backing. Your support directly sustains development. desc: 'GitJournal is completely open source and is the result of significant development work. It has no venture capital or corporation backing. Your support directly sustains development.
Paying a monthly subscription helps you support development and gives you access to GitJournal operates on a "pay what you want model". No matter what you pay you will get access to all the Pro features.'
a number of "Pro" only features. We operate on a "pay what you want model". No matter what you pay
you will get access to all the Pro features.'
restore: Restore Purchase restore: Restore Purchase

View File

@ -30,7 +30,12 @@ class PurchaseScreen extends StatelessWidget {
style: Theme.of(context).textTheme.bodyText2, style: Theme.of(context).textTheme.bodyText2,
), ),
const SizedBox(height: 32.0), const SizedBox(height: 32.0),
const MonthlyRentalWidget(), PurchaseCards(
children: [
const MonthlyRentalWidget(),
const YearlyPurchaseWidget(),
],
),
const SizedBox(height: 32.0), const SizedBox(height: 32.0),
Row( Row(
children: [ children: [
@ -78,23 +83,22 @@ class MonthlyRentalWidget extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var textTheme = Theme.of(context).textTheme; var textTheme = Theme.of(context).textTheme;
return Card( return PurchaseCard(
shape: RoundedRectangleBorder( child: Column(
borderRadius: BorderRadius.circular(15.0), children: [
), // TODO: Translate this
child: Padding( Text("Monthly Rental", style: textTheme.headline5),
padding: const EdgeInsets.fromLTRB(16.0, 32.0, 16.0, 32.0), const SizedBox(height: 32.0),
child: Column( PurchaseWidget(
children: [ skus: _generateSkus(),
Text("Monthly Subscription", style: textTheme.headline5), defaultSku: "sku_monthly_min3",
const SizedBox(height: 32.0), timePeriod: "Month",
PurchaseWidget( ),
skus: _generateSkus(), const SizedBox(height: 32.0),
defaultSku: "sku_monthly_min3", const Text(
timePeriod: "Month", "After 12 months of rental or after paying the min yearly amount, you will automatically get all the benefits of a Yearly Purchase."),
), ],
], mainAxisAlignment: MainAxisAlignment.start,
),
), ),
); );
} }
@ -117,26 +121,21 @@ class YearlyPurchaseWidget extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var textTheme = Theme.of(context).textTheme; var textTheme = Theme.of(context).textTheme;
return Card( return PurchaseCard(
shape: RoundedRectangleBorder( child: Column(
borderRadius: BorderRadius.circular(15.0), children: [
), Text("Yearly Purchase", style: textTheme.headline5),
child: Padding( const SizedBox(height: 32.0),
padding: const EdgeInsets.fromLTRB(16.0, 32.0, 16.0, 32.0), PurchaseWidget(
child: Column( skus: _generateSkus(),
children: [ defaultSku: "sku_sub_yearly_1",
Text("Yearly Purchase", style: textTheme.headline5), timePeriod: "Year",
const SizedBox(height: 32.0), ),
PurchaseWidget( const SizedBox(height: 32.0),
skus: _generateSkus(), const Text(
defaultSku: "sku_sub_yearly_0", "Enables all Pro features currently in GitJournal and new features added in the following 12 months. These features will be yours forever.")
timePeriod: "Year", ],
), mainAxisAlignment: MainAxisAlignment.start,
const SizedBox(height: 8.0),
const Text(
"Enables all Pro features currently in GitJournal and new ones added the next year. These features will be yours forever.")
],
),
), ),
); );
} }
@ -149,3 +148,75 @@ class YearlyPurchaseWidget extends StatelessWidget {
return list; return list;
} }
} }
class PurchaseCard extends StatelessWidget {
final Widget child;
PurchaseCard({@required this.child});
@override
Widget build(BuildContext context) {
var mediaQuery = MediaQuery.of(context);
return Container(
width: mediaQuery.size.width * 0.80,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 16.0),
child: child,
),
),
);
}
}
class PurchaseCards extends StatefulWidget {
final List<Widget> children;
PurchaseCards({@required this.children});
@override
_PurchaseCardsState createState() => _PurchaseCardsState();
}
class _PurchaseCardsState extends State<PurchaseCards> {
@override
Widget build(BuildContext context) {
return _ScrollViewWithoutAnim(
scrollDirection: Axis.horizontal,
child: IntrinsicHeight(
child: Row(
children: widget.children,
mainAxisSize: MainAxisSize.min,
),
),
);
}
}
class _ScrollViewWithoutAnim extends StatelessWidget {
final Widget child;
final Axis scrollDirection;
_ScrollViewWithoutAnim({
@required this.child,
this.scrollDirection,
});
@override
Widget build(BuildContext context) {
return NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overScroll) {
overScroll.disallowGlow();
return false;
},
child: SingleChildScrollView(
scrollDirection: scrollDirection,
child: child,
),
);
}
}

View File

@ -265,7 +265,7 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
], ],
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
), ),
const SizedBox(height: 16.0), const SizedBox(height: 32.0),
PurchaseButton(_selectedProduct, widget.timePeriod), PurchaseButton(_selectedProduct, widget.timePeriod),
], ],
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,