mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
CWA-216 | applied new design to disclaimer page and faq page
This commit is contained in:
parent
1bed82327b
commit
2356cda879
2 changed files with 338 additions and 267 deletions
|
@ -1,11 +1,11 @@
|
|||
import 'dart:convert';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
||||
class FaqPage extends BasePage {
|
||||
@override
|
||||
|
@ -15,7 +15,23 @@ class FaqPage extends BasePage {
|
|||
Color get backgroundColor => PaletteDark.historyPanel;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
Widget body(BuildContext context) => FaqForm();
|
||||
}
|
||||
|
||||
class FaqForm extends StatefulWidget {
|
||||
@override
|
||||
FaqFormState createState() => FaqFormState();
|
||||
}
|
||||
|
||||
class FaqFormState extends State<FaqForm> {
|
||||
final addIcon = Icon(Icons.add, color: Colors.white);
|
||||
final removeIcon = Icon(Icons.remove, color: Colors.green);
|
||||
List<Icon> icons;
|
||||
List<Color> colors;
|
||||
bool isLoaded = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: PaletteDark.historyPanel,
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
|
@ -25,36 +41,79 @@ class FaqPage extends BasePage {
|
|||
builder: (context, snapshot) {
|
||||
final faqItems = jsonDecode(snapshot.data.toString()) as List;
|
||||
|
||||
return ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final itemTitle = faqItems[index]["question"].toString();
|
||||
final itemChild = faqItems[index]["answer"].toString();
|
||||
if (snapshot.hasData) {
|
||||
setIconsAndColors(faqItems.length);
|
||||
}
|
||||
|
||||
return ExpansionTile(
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 8, top: 12, bottom: 12),
|
||||
child: Text(itemTitle),
|
||||
),
|
||||
backgroundColor: PaletteDark.menuHeader,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 24.0, right: 24.0, bottom: 4),
|
||||
child: Text(
|
||||
itemChild,
|
||||
),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) =>
|
||||
Divider(color: PaletteDark.mainBackgroundColor, height: 1.0),
|
||||
itemCount: faqItems == null ? 0 : faqItems.length,
|
||||
return SingleChildScrollView(
|
||||
child: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final itemTitle = faqItems[index]["question"].toString();
|
||||
final itemChild = faqItems[index]["answer"].toString();
|
||||
|
||||
return ExpansionTile(
|
||||
title: Padding(
|
||||
padding: EdgeInsets.only(left: 8, top: 12, bottom: 12),
|
||||
child: Text(
|
||||
itemTitle,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: colors[index]
|
||||
),
|
||||
),
|
||||
),
|
||||
trailing: Padding(
|
||||
padding: EdgeInsets.only(right: 24),
|
||||
child: Container(
|
||||
width: double.minPositive,
|
||||
child: Center(
|
||||
child: icons[index]
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: PaletteDark.menuHeader,
|
||||
onExpansionChanged: (value) {
|
||||
setState(() {
|
||||
if (value) {
|
||||
icons[index] = removeIcon;
|
||||
colors[index] = Colors.green;
|
||||
} else {
|
||||
icons[index] = addIcon;
|
||||
colors[index] = Colors.white;
|
||||
}
|
||||
});
|
||||
},
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 24.0,
|
||||
right: 24.0,
|
||||
bottom: 8
|
||||
),
|
||||
child: Text(
|
||||
itemChild,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.white
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, __) =>
|
||||
Container(color: PaletteDark.mainBackgroundColor, height: 1.0),
|
||||
itemCount: faqItems == null ? 0 : faqItems.length,
|
||||
),
|
||||
);
|
||||
},
|
||||
future: rootBundle.loadString(getFaqPath(context)),
|
||||
|
@ -63,6 +122,17 @@ class FaqPage extends BasePage {
|
|||
);
|
||||
}
|
||||
|
||||
void setIconsAndColors(int index) {
|
||||
if (isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
icons = List.generate(index, (int i) => addIcon);
|
||||
colors = List.generate(index, (int i) => Colors.white);
|
||||
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
String getFaqPath(BuildContext context) {
|
||||
final settingsStore = Provider.of<SettingsStore>(context);
|
||||
|
||||
|
@ -95,4 +165,4 @@ class FaqPage extends BasePage {
|
|||
return 'assets/faq/faq_en.json';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue