Skip to content

Commit

Permalink
added code for faqs screen
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherwebguy committed Mar 18, 2021
1 parent 6fb8b03 commit 6b46928
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 95 deletions.
Binary file added assets/FAQ.pdf
Binary file not shown.
124 changes: 124 additions & 0 deletions lib/views/faqs_Screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 1,124 @@
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
import 'package:flutter/material.dart';
import 'package:retro_shopping/helpers/constants.dart';
import 'package:retro_shopping/widgets/retro_button.dart';

class FaqsScreen extends StatefulWidget {
@override
_FaqsScreenState createState() => _FaqsScreenState();
}

class _FaqsScreenState extends State<FaqsScreen> {

bool _loading=true;
PDFDocument doc;

@override
void initState() {
// TODO: implement initState
super.initState();
loadDocument();
}

loadDocument() async {
doc = await PDFDocument.fromAsset('assets/FAQ.pdf');

setState(() => _loading = false);
}

changePDF(value) async {
setState(() => _loading = true);
if (value == 1) {
doc = await PDFDocument.fromAsset('assets/FAQ.pdf');
} else if (value == 2) {
doc = await PDFDocument.fromURL(
"http://conorlastowka.com/book/CitationNeededBook-Sample.pdf",
/* cacheManager: CacheManager(
Config(
"customCacheKey",
stalePeriod: const Duration(days: 2),
maxNrOfCacheObjects: 10,
),
), */
);
} else {
doc = await PDFDocument.fromAsset('assets/FAQ.pdf');
}
setState(() => _loading = false);
}


@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: RelicColors.backgroundColor,
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: RetroButton(
upperColor: Colors.white,
lowerColor: Colors.black,
width: 35,
height: 35,
borderColor: Colors.white,
child: const Icon(
Icons.arrow_back,
color: Colors.black,
),
),
),
),
title: Text("FAQs"),
elevation: 0.0,
),
body: Center(
child: _loading
? Center(child: CircularProgressIndicator())
: PDFViewer(
document: doc,
zoomSteps: 1,
scrollDirection: Axis.vertical,
//uncomment below line to preload all pages
// lazyLoad: false,
//uncomment below code to replace bottom navigation with your own
/* navigationBuilder:
(context, page, totalPages, jumpToPage, animateToPage) {
return ButtonBar(
alignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(Icons.first_page),
onPressed: () {
jumpToPage()(page: 0);
},
),
IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
animateToPage(page: page - 2);
},
),
IconButton(
icon: Icon(Icons.arrow_forward),
onPressed: () {
animateToPage(page: page);
},
),
IconButton(
icon: Icon(Icons.last_page),
onPressed: () {
jumpToPage(page: totalPages - 1);
},
),
],
);
}, */
),
),
);
}
}
194 changes: 99 additions & 95 deletions lib/views/settings.dart
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
import 'package:flutter/material.dart';
import 'package:retro_shopping/helpers/constants.dart';
import 'package:retro_shopping/views/address_screen.dart';
import 'package:retro_shopping/views/faqs_Screen.dart';
import 'package:retro_shopping/views/orders.dart';
import 'package:retro_shopping/widgets/retro_button.dart';
import 'package:retro_shopping/widgets/settings_item.dart';
Expand Down Expand Up @@ -64,102 65,105 @@ class _SettingsState extends State<Settings> {
height: MediaQuery.of(context).size.height * 0.85 5,
decoration:
const BoxDecoration(color: RelicColors.primaryColor),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
settingsItem(context, 'Your Orders',
Icons.bookmark_border_sharp,
tags: Order()),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'Change Username/\nPassword',
Icons.person),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'FAQs', Icons.question_answer),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(
context, 'Manage Address', Icons.location_pin,
tags: AddressScreen()),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(
context, 'T&C', Icons.quick_contacts_dialer),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
Row(
children: <Widget>[
const SizedBox(
height: 70,
),
Expanded(
child: Row(
children: const <Widget>[
SizedBox(
width: 5,
),
Icon(
Icons.notifications_active,
size: 30,
color: Colors.white,
),
SizedBox(
width: 5,
),
Text('Notifications(on/off)',
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 20))
],
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
settingsItem(context, 'Your Orders',
Icons.bookmark_border_sharp,
tags: Order()),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'Change Username/\nPassword',
Icons.person),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'FAQs', Icons.question_answer,tags: FaqsScreen()),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(
context, 'Manage Address', Icons.location_pin,
tags: AddressScreen()),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(
context, 'T&C', Icons.quick_contacts_dialer),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
Row(
children: <Widget>[
const SizedBox(
height: 70,
),
),
Switch(
value: switchedOn,
onChanged: (bool value) {
setState(() {
switchedOn = value;
});
},
activeColor: Colors.white,
activeTrackColor: Colors.black,
)
],
),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'LogOut', Icons.logout),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'GitHub Repo Link',
Icons.verified_user_outlined),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
],
Expanded(
child: Row(
children: const <Widget>[
SizedBox(
width: 5,
),
Icon(
Icons.notifications_active,
size: 30,
color: Colors.white,
),
SizedBox(
width: 5,
),
Text('Notifications(on/off)',
style: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 20))
],
),
),
Switch(
value: switchedOn,
onChanged: (bool value) {
setState(() {
switchedOn = value;
});
},
activeColor: Colors.white,
activeTrackColor: Colors.black,
)
],
),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'LogOut', Icons.logout),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
settingsItem(context, 'GitHub Repo Link',
Icons.verified_user_outlined),
Padding(
padding:
const EdgeInsets.only(left: 16.0, right: 16.0),
child: divider(),
),
],
),
),
),
],
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 37,7 @@ dependencies:
geocoder: 0.2.1
flutter_svg: ^0.20.0-nullsafety.3
provider: ^5.0.0
advance_pdf_viewer: ^1.2.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 6b46928

Please sign in to comment.