Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active April 3, 2020 00:29
Show Gist options
  • Save VB10/70ffded7867edd32e9e8b55c3a678d0f to your computer and use it in GitHub Desktop.
Save VB10/70ffded7867edd32e9e8b55c3a678d0f to your computer and use it in GitHub Desktop.
Shoppi - Home
class ShopView extends StatefulWidget {
@override
_ShopViewState createState() => _ShopViewState();
}
class _ShopViewState extends BaseState<ShopView> {
List<Product> subList = [];
int currentPage = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: currentTheme.primaryColor,
body: PageView(
controller: PageController(viewportFraction: pageViewHeight),
onPageChanged: (value) => onPageChanged(value),
scrollDirection: Axis.vertical,
children: <Widget>[
ShopListView(isUserOnPage: isShopPage),
ShopPaymentView()
],
),
);
}
bool get isShopPage => currentPage == PageViews.PRODUCT_LIST.index;
void onPageChanged(int val) {
setState(() {
currentPage = val;
});
}
double get pageViewHeight => currentPage == 1 ? 0.8 : 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment