-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from anotherwebguy/#38faqs
added code for faqs screen
Showing
4 changed files
with
179 additions
and
95 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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(); | ||
} | ||
|
||
Future<void> loadDocument() async { | ||
_doc = await PDFDocument.fromAsset('assets/FAQ.pdf'); | ||
|
||
setState(() => _loading = false); | ||
} | ||
|
||
Future<void> changePDF(int 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', | ||
); | ||
} 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: const Text('FAQs'), | ||
elevation: 0.0, | ||
), | ||
body: Center( | ||
child: _loading | ||
? const Center(child: CircularProgressIndicator()) | ||
: PDFViewer( | ||
document: _doc, | ||
zoomSteps: 1, | ||
scrollDirection: Axis.vertical, | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters