cake_wallet/lib/src/screens/faq/faq_page.dart

53 lines
1.7 KiB
Dart
Raw Normal View History

2020-01-04 19:31:52 +00:00
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:cake_wallet/generated/i18n.dart';
2020-09-28 15:47:43 +00:00
import 'package:cake_wallet/src/screens/faq/faq_item.dart';
2020-01-04 19:31:52 +00:00
import 'package:cake_wallet/src/screens/base_page.dart';
2020-09-28 15:47:43 +00:00
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/store/settings_store.dart';
2020-01-04 19:31:52 +00:00
class FaqPage extends BasePage {
2020-09-28 15:47:43 +00:00
FaqPage(this.settingsStore);
2020-01-04 19:31:52 +00:00
2020-09-28 15:47:43 +00:00
final SettingsStore settingsStore;
@override
2020-09-28 15:47:43 +00:00
String get title => S.current.faq;
2020-09-28 15:47:43 +00:00
String get path => 'assets/faq/faq_' + settingsStore.languageCode + '.json';
@override
2020-09-28 15:47:43 +00:00
Widget body(BuildContext context) {
return Container(
padding: EdgeInsets.only(top: 12, left: 24),
child: FutureBuilder(
builder: (context, snapshot) {
final faqItems = jsonDecode(snapshot.data.toString()) as List;
2020-01-04 19:31:52 +00:00
return SingleChildScrollView(
child: Column(
children: <Widget>[
StandardListSeparator(),
ListView.separated(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
2020-09-28 15:47:43 +00:00
final title = faqItems[index]["question"].toString();
final text = faqItems[index]["answer"].toString();
2020-01-04 19:31:52 +00:00
2020-09-28 15:47:43 +00:00
return FAQItem(title, text);
},
2020-09-28 15:47:43 +00:00
separatorBuilder: (_, __) => StandardListSeparator(),
itemCount: faqItems?.length ?? 0,
)
],
),
);
},
2020-09-28 15:47:43 +00:00
future: rootBundle.loadString(path),
),
2020-01-04 19:31:52 +00:00
);
}
2020-09-28 15:47:43 +00:00
}