Moved FAQ Button to Home Screen

This commit is contained in:
Matthew Patrick 2022-05-25 21:14:08 +07:00
parent 17792098b0
commit 5883059a87
2 changed files with 66 additions and 66 deletions

View file

@ -6,6 +6,7 @@ import 'package:nekoya_flutter/components/new_arrival_products.dart';
import 'package:nekoya_flutter/components/newsletter.dart'; import 'package:nekoya_flutter/components/newsletter.dart';
import 'package:nekoya_flutter/components/popular_products.dart'; import 'package:nekoya_flutter/components/popular_products.dart';
import 'package:nekoya_flutter/components/search_form.dart'; import 'package:nekoya_flutter/components/search_form.dart';
import 'package:nekoya_flutter/screens/faq.dart';
import 'package:nekoya_flutter/utils/utils.dart'; import 'package:nekoya_flutter/utils/utils.dart';
class Home extends StatelessWidget { class Home extends StatelessWidget {
@ -20,6 +21,15 @@ class Home extends StatelessWidget {
centerTitle: true, centerTitle: true,
backgroundColor: const Color(0xff212226), backgroundColor: const Color(0xff212226),
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
actions: [
IconButton(
icon: const Icon(Icons.question_mark),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => const FAQ()));
},
)
],
), ),
body: SafeArea( body: SafeArea(
child: SingleChildScrollView( child: SingleChildScrollView(

View file

@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
import 'package:nekoya_flutter/api/api.dart'; import 'package:nekoya_flutter/api/api.dart';
import 'package:nekoya_flutter/components/product_box.dart'; import 'package:nekoya_flutter/components/product_box.dart';
import 'package:nekoya_flutter/components/product_detail.dart'; import 'package:nekoya_flutter/components/product_detail.dart';
import 'package:nekoya_flutter/screens/faq.dart'; import 'package:nekoya_flutter/utils/utils.dart'
import 'package:nekoya_flutter/utils/utils.dart' show kMobileBreakpoint, kTabletBreakpoint, kDesktopBreakPoint; show kMobileBreakpoint, kTabletBreakpoint, kDesktopBreakPoint;
class Products extends StatefulWidget { class Products extends StatefulWidget {
const Products({Key? key}) : super(key: key); const Products({Key? key}) : super(key: key);
@ -23,72 +23,62 @@ class _ProductsState extends State<Products> {
centerTitle: true, centerTitle: true,
backgroundColor: const Color(0xff212226), backgroundColor: const Color(0xff212226),
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
actions: [
IconButton(
icon: const Icon(Icons.question_mark),
onPressed: () {
Navigator.push(context, MaterialPageRoute(
builder: (context) => const FAQ()
));
},
)
],
), ),
body: LayoutBuilder( body: LayoutBuilder(builder: (context, dimension) {
builder: (context, dimension) { int gridCount = 2;
int gridCount = 2; double fontSize = 14.0;
double fontSize = 14.0;
if (dimension.maxWidth <= kMobileBreakpoint) { if (dimension.maxWidth <= kMobileBreakpoint) {
gridCount = 2; gridCount = 2;
fontSize = 14.0; fontSize = 14.0;
} else if (dimension.maxWidth > kMobileBreakpoint && } else if (dimension.maxWidth > kMobileBreakpoint &&
dimension.maxWidth <= kTabletBreakpoint) { dimension.maxWidth <= kTabletBreakpoint) {
gridCount = 4; gridCount = 4;
fontSize = 15.0; fontSize = 15.0;
} else if (dimension.maxWidth > kTabletBreakpoint && } else if (dimension.maxWidth > kTabletBreakpoint &&
dimension.maxWidth <= kDesktopBreakPoint) { dimension.maxWidth <= kDesktopBreakPoint) {
gridCount = 5; gridCount = 5;
fontSize = 10.0; fontSize = 10.0;
} else { } else {
gridCount = 6; gridCount = 6;
fontSize = 10.0; fontSize = 10.0;
}
return FutureBuilder<dynamic>(
future: getProducts(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var data = snapshot.data;
return GridView.count(
crossAxisCount: gridCount,
children: List.generate(data!.length, (index) {
return ProductBox(
imageUrl: "https://nekoya.moe.team/img/${data[index]['IMAGE']}",
title: data[index]['TITLE'],
fontSize: fontSize,
callback: () {
showModalBottomSheet(
isScrollControlled: true,
backgroundColor: Colors.transparent,
context: context,
builder: (context) => productDetail(context, data[index]['ID']),
);
},
);
}),
);
}
return const Center(
child: CircularProgressIndicator(
color: Color(0xff8B0000),
),
);
},
);
} }
),
return FutureBuilder<dynamic>(
future: getProducts(),
builder: (context, snapshot) {
if (snapshot.hasData) {
var data = snapshot.data;
return GridView.count(
crossAxisCount: gridCount,
children: List.generate(data!.length, (index) {
return ProductBox(
imageUrl:
"https://nekoya.moe.team/img/${data[index]['IMAGE']}",
title: data[index]['TITLE'],
fontSize: fontSize,
callback: () {
showModalBottomSheet(
isScrollControlled: true,
backgroundColor: Colors.transparent,
context: context,
builder: (context) =>
productDetail(context, data[index]['ID']),
);
},
);
}),
);
}
return const Center(
child: CircularProgressIndicator(
color: Color(0xff8B0000),
),
);
},
);
}),
); );
} }
} }