mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
PurchaseScreen: Fix scrolling
Putting a column inside a SingleChildScrollView is way way too complex. There are lots of different solutions, and not all seem to work for me. Also adjust the loading screen.
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -48,6 +47,7 @@ class PurchaseScreen extends StatelessWidget {
|
||||
var body = Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Support GitJournal by going Pro and additionally get -',
|
||||
@ -77,10 +77,13 @@ class PurchaseScreen extends StatelessWidget {
|
||||
style: titleStyle,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 32.0),
|
||||
body,
|
||||
const SizedBox(height: 32.0),
|
||||
PurchaseWidget(),
|
||||
],
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
);
|
||||
|
||||
if (Platform.isIOS) {
|
||||
@ -99,10 +102,17 @@ class PurchaseScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return _SingleChildScrollViewExpanded(
|
||||
child: SafeArea(child: w),
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
);
|
||||
w = Padding(padding: const EdgeInsets.all(16.0), child: w);
|
||||
|
||||
return SafeArea(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
SliverFillRemaining(
|
||||
hasScrollBody: false,
|
||||
child: w,
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Future<bool> _onWillPop() async {
|
||||
@ -122,26 +132,3 @@ class EmptyAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
Size get preferredSize => const Size(0.0, 0.0);
|
||||
}
|
||||
|
||||
class _SingleChildScrollViewExpanded extends StatelessWidget {
|
||||
final Widget child;
|
||||
final EdgeInsetsGeometry padding;
|
||||
|
||||
_SingleChildScrollViewExpanded({this.child, this.padding});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints.tightFor(
|
||||
height: max(100, constraints.maxHeight)),
|
||||
child: child,
|
||||
),
|
||||
padding: padding,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -77,55 +77,6 @@ class PurchaseButton extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class LoadingWidget extends StatelessWidget {
|
||||
const LoadingWidget({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var theme = Theme.of(context);
|
||||
var children = <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
"Loading",
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8.0),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: CircularProgressIndicator(
|
||||
value: null,
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
var w = Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: children,
|
||||
);
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: _onWillPopLoading,
|
||||
child: Container(
|
||||
child: w,
|
||||
color: theme.scaffoldBackgroundColor,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
constraints: const BoxConstraints.expand(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> _onWillPopLoading() async {
|
||||
getAnalytics().logEvent(
|
||||
name: "purchase_screen_close_loading",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class PurchaseWidget extends StatefulWidget {
|
||||
@override
|
||||
_PurchaseWidgetState createState() => _PurchaseWidgetState();
|
||||
@ -207,7 +158,9 @@ class _PurchaseWidgetState extends State<PurchaseWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _offerings == null ? const LoadingWidget() : buildBody(context);
|
||||
return _offerings == null
|
||||
? const CircularProgressIndicator()
|
||||
: buildBody(context);
|
||||
}
|
||||
|
||||
Widget buildBody(BuildContext context) {
|
||||
|
Reference in New Issue
Block a user