mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 14:28:40 +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",
|
"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.",
|
"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",
|
"settingsHelp": "Hilfe",
|
||||||
"settingsHelpSupport": "Support-Center",
|
"settingsHelpFAQ": "FAQ",
|
||||||
"settingsHelpContactUs": "Kontaktiere uns",
|
"settingsHelpContactUs": "Kontaktiere uns",
|
||||||
"settingsHelpDiagnostics": "Diagnoseprotokoll",
|
"settingsHelpDiagnostics": "Diagnoseprotokoll",
|
||||||
"settingsHelpVersion": "Version",
|
"settingsHelpVersion": "Version",
|
||||||
|
|
|
||||||
|
|
@ -209,8 +209,8 @@
|
||||||
"@settingsHelp": {},
|
"@settingsHelp": {},
|
||||||
"settingsHelpDiagnostics": "Diagnostic protocol",
|
"settingsHelpDiagnostics": "Diagnostic protocol",
|
||||||
"@settingsHelpDiagnostics": {},
|
"@settingsHelpDiagnostics": {},
|
||||||
"settingsHelpSupport": "Support Center",
|
"settingsHelpFAQ": "FAQ",
|
||||||
"@settingsHelpSupport": {},
|
"@settingsHelpFAQ": {},
|
||||||
"settingsHelpContactUs": "Contact us",
|
"settingsHelpContactUs": "Contact us",
|
||||||
"@settingsHelpContactUs": {},
|
"@settingsHelpContactUs": {},
|
||||||
"settingsHelpVersion": "Version",
|
"settingsHelpVersion": "Version",
|
||||||
|
|
|
||||||
|
|
@ -713,11 +713,11 @@ abstract class AppLocalizations {
|
||||||
/// **'Diagnostic protocol'**
|
/// **'Diagnostic protocol'**
|
||||||
String get settingsHelpDiagnostics;
|
String get settingsHelpDiagnostics;
|
||||||
|
|
||||||
/// No description provided for @settingsHelpSupport.
|
/// No description provided for @settingsHelpFAQ.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
/// **'Support Center'**
|
/// **'FAQ'**
|
||||||
String get settingsHelpSupport;
|
String get settingsHelpFAQ;
|
||||||
|
|
||||||
/// No description provided for @settingsHelpContactUs.
|
/// No description provided for @settingsHelpContactUs.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||||
String get settingsHelpDiagnostics => 'Diagnoseprotokoll';
|
String get settingsHelpDiagnostics => 'Diagnoseprotokoll';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get settingsHelpSupport => 'Support-Center';
|
String get settingsHelpFAQ => 'FAQ';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get settingsHelpContactUs => 'Kontaktiere uns';
|
String get settingsHelpContactUs => 'Kontaktiere uns';
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||||
String get settingsHelpDiagnostics => 'Diagnostic protocol';
|
String get settingsHelpDiagnostics => 'Diagnostic protocol';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get settingsHelpSupport => 'Support Center';
|
String get settingsHelpFAQ => 'FAQ';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get settingsHelpContactUs => 'Contact us';
|
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/contact_us_view.dart';
|
||||||
import 'package:twonly/src/views/settings/help/credits_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/diagnostics_view.dart';
|
||||||
|
import 'package:twonly/src/views/settings/help/faq.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class HelpView extends StatelessWidget {
|
class HelpView extends StatelessWidget {
|
||||||
|
|
@ -18,11 +19,13 @@ class HelpView extends StatelessWidget {
|
||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(context.lang.settingsHelpSupport),
|
title: Text(context.lang.settingsHelpFAQ),
|
||||||
onTap: () {
|
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(
|
ListTile(
|
||||||
title: Text(context.lang.settingsHelpContactUs),
|
title: Text(context.lang.settingsHelpContactUs),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue