mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 09:28:41 +00:00
fix #159
This commit is contained in:
parent
37b46f1f83
commit
001a0bb2c1
7 changed files with 120 additions and 11 deletions
|
|
@ -118,7 +118,7 @@
|
|||
"settingsNotifyTroubleshootingNoProblem": "Kein Problem festgestellt",
|
||||
"settingsNotifyTroubleshootingNoProblemDesc": "Klicke auf OK, um eine Testbenachrichtigung zu erhalten. Wenn du auch nach 10 Minuten warten keine Nachricht erhältst, sende uns bitte dein Diagnoseprotokoll unter Einstellungen > Hilfe > Diagnoseprotokoll, damit wir uns das Problem ansehen können.",
|
||||
"settingsHelp": "Hilfe",
|
||||
"settingsHelpSupport": "Support-Center",
|
||||
"settingsHelpFAQ": "FAQ",
|
||||
"settingsHelpContactUs": "Kontaktiere uns",
|
||||
"settingsHelpDiagnostics": "Diagnoseprotokoll",
|
||||
"settingsHelpVersion": "Version",
|
||||
|
|
|
|||
|
|
@ -209,8 +209,8 @@
|
|||
"@settingsHelp": {},
|
||||
"settingsHelpDiagnostics": "Diagnostic protocol",
|
||||
"@settingsHelpDiagnostics": {},
|
||||
"settingsHelpSupport": "Support Center",
|
||||
"@settingsHelpSupport": {},
|
||||
"settingsHelpFAQ": "FAQ",
|
||||
"@settingsHelpFAQ": {},
|
||||
"settingsHelpContactUs": "Contact us",
|
||||
"@settingsHelpContactUs": {},
|
||||
"settingsHelpVersion": "Version",
|
||||
|
|
|
|||
|
|
@ -713,11 +713,11 @@ abstract class AppLocalizations {
|
|||
/// **'Diagnostic protocol'**
|
||||
String get settingsHelpDiagnostics;
|
||||
|
||||
/// No description provided for @settingsHelpSupport.
|
||||
/// No description provided for @settingsHelpFAQ.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Support Center'**
|
||||
String get settingsHelpSupport;
|
||||
/// **'FAQ'**
|
||||
String get settingsHelpFAQ;
|
||||
|
||||
/// No description provided for @settingsHelpContactUs.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||
String get settingsHelpDiagnostics => 'Diagnoseprotokoll';
|
||||
|
||||
@override
|
||||
String get settingsHelpSupport => 'Support-Center';
|
||||
String get settingsHelpFAQ => 'FAQ';
|
||||
|
||||
@override
|
||||
String get settingsHelpContactUs => 'Kontaktiere uns';
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||
String get settingsHelpDiagnostics => 'Diagnostic protocol';
|
||||
|
||||
@override
|
||||
String get settingsHelpSupport => 'Support Center';
|
||||
String get settingsHelpFAQ => 'FAQ';
|
||||
|
||||
@override
|
||||
String get settingsHelpContactUs => 'Contact us';
|
||||
|
|
|
|||
106
lib/src/views/settings/help/faq.dart
Normal file
106
lib/src/views/settings/help/faq.dart
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class FAQPage extends StatefulWidget {
|
||||
const FAQPage({super.key});
|
||||
|
||||
@override
|
||||
State<FAQPage> createState() => _FAQPageState();
|
||||
}
|
||||
|
||||
class _FAQPageState extends State<FAQPage> {
|
||||
Map<String, dynamic>? _faqData;
|
||||
String? _locale;
|
||||
late String domain;
|
||||
bool noInternet = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
domain = "http://10.99.0.140:8000";
|
||||
_fetchFAQData();
|
||||
}
|
||||
|
||||
Future<void> _fetchFAQData() async {
|
||||
try {
|
||||
final response = await http.get(Uri.parse("$domain/faq.json"));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
_locale = Localizations.localeOf(context).languageCode;
|
||||
setState(() {
|
||||
// print(response.body);
|
||||
_faqData = json.decode(utf8.decode(response.body.codeUnits));
|
||||
});
|
||||
} else {
|
||||
// throw Exception('Failed to load FAQ data');
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
noInternet = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (noInternet) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(context.lang.settingsHelpFAQ),
|
||||
),
|
||||
body: Center(
|
||||
child: Text("Could not load the FAQ."),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (_faqData == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(context.lang.settingsHelpFAQ),
|
||||
),
|
||||
body: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
final faq = _faqData![_locale ?? 'en'];
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(context.lang.settingsHelpFAQ),
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: faq.keys.length,
|
||||
itemBuilder: (context, index) {
|
||||
String category = faq.keys.elementAt(index);
|
||||
var categoryData = faq[category];
|
||||
|
||||
return Card(
|
||||
child: ExpansionTile(
|
||||
title: Text(categoryData['meta']['title']),
|
||||
subtitle: Text(categoryData['meta']['desc']),
|
||||
children: categoryData['questions'].map<Widget>((question) {
|
||||
return ListTile(
|
||||
title: Text(question['title']),
|
||||
onTap: () => _launchURL(question['path']),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _launchURL(String path) async {
|
||||
try {
|
||||
await launchUrl(Uri.parse("$domain$path"));
|
||||
} catch (e) {
|
||||
Logger("launchUrl").shout("Could not launch $e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import 'package:twonly/src/utils/misc.dart';
|
|||
import 'package:twonly/src/views/settings/help/contact_us_view.dart';
|
||||
import 'package:twonly/src/views/settings/help/credits_view.dart';
|
||||
import 'package:twonly/src/views/settings/help/diagnostics_view.dart';
|
||||
import 'package:twonly/src/views/settings/help/faq.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class HelpView extends StatelessWidget {
|
||||
|
|
@ -18,11 +19,13 @@ class HelpView extends StatelessWidget {
|
|||
body: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(context.lang.settingsHelpSupport),
|
||||
title: Text(context.lang.settingsHelpFAQ),
|
||||
onTap: () {
|
||||
launchUrl(Uri.parse("https://twonly.eu/support"));
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return FAQPage();
|
||||
}));
|
||||
},
|
||||
trailing: FaIcon(FontAwesomeIcons.arrowUpRightFromSquare, size: 15),
|
||||
// trailing: FaIcon(FontAwesomeIcons.arrowUpRightFromSquare, size: 15),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(context.lang.settingsHelpContactUs),
|
||||
|
|
|
|||
Loading…
Reference in a new issue