ente/lib/ui/settings/support_section_widget.dart

109 lines
3.5 KiB
Dart
Raw Normal View History

// @dart=2.9
2022-06-28 14:39:17 +00:00
import 'dart:io';
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/ente_theme_data.dart';
import 'package:photos/ui/common/web_page.dart';
import 'package:photos/ui/components/captioned_text_widget.dart';
import 'package:photos/ui/components/menu_item_widget.dart';
import 'package:photos/ui/settings/common_settings.dart';
import 'package:photos/ui/settings/settings_text_item.dart';
2021-06-12 10:33:24 +00:00
import 'package:photos/utils/email_util.dart';
class SupportSectionWidget extends StatefulWidget {
const SupportSectionWidget({Key key}) : super(key: key);
@override
State<SupportSectionWidget> createState() => _SupportSectionWidgetState();
}
class _SupportSectionWidgetState extends State<SupportSectionWidget> {
final expandableController = ExpandableController(initialExpanded: false);
@override
void dispose() {
expandableController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ExpandablePanel(
header: MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
text: "Support",
),
isHeaderOfExpansion: true,
leadingIcon: Icons.help_outline_outlined,
trailingIcon: Icons.expand_more,
menuItemColor:
Theme.of(context).colorScheme.enteTheme.colorScheme.fillFaint,
expandableController: expandableController,
),
collapsed: Container(),
expanded: _getSectionOptions(context),
theme: getExpandableTheme(context),
controller: expandableController,
);
}
Widget _getSectionOptions(BuildContext context) {
2022-06-28 14:39:17 +00:00
final String bugsEmail =
Platform.isAndroid ? "android-bugs@ente.io" : "ios-bugs@ente.io";
2021-07-28 15:41:45 +00:00
return Column(
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
await sendEmail(context, to: supportEmail);
},
2022-07-04 06:02:17 +00:00
child:
const SettingsTextItem(text: "Email", icon: Icons.navigate_next),
2021-05-07 22:44:03 +00:00
),
sectionOptionDivider,
2021-05-25 14:01:03 +00:00
GestureDetector(
behavior: HitTestBehavior.translucent,
2021-05-25 14:02:13 +00:00
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
final endpoint = Configuration.instance.getHttpEndpoint() +
"/users/roadmap";
final isLoggedIn = Configuration.instance.getToken() != null;
final url = isLoggedIn
? endpoint + "?token=" + Configuration.instance.getToken()
: roadmapURL;
2022-06-18 12:23:51 +00:00
return WebPage("Roadmap", url);
2021-05-25 14:02:13 +00:00
},
),
);
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
text: "Roadmap",
icon: Icons.navigate_next,
),
2021-05-25 14:02:13 +00:00
),
sectionOptionDivider,
2021-08-09 07:10:05 +00:00
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
2022-06-28 14:39:17 +00:00
await sendLogs(context, "Report bug", bugsEmail);
2021-08-09 07:10:05 +00:00
},
onDoubleTap: () async {
final zipFilePath = await getZippedLogsFile(context);
2022-06-28 14:39:17 +00:00
await shareLogs(context, bugsEmail, zipFilePath);
2022-06-06 10:32:10 +00:00
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
2022-06-11 08:23:52 +00:00
text: "Report bug 🐞",
icon: Icons.navigate_next,
),
2021-08-09 07:10:05 +00:00
),
2021-07-28 15:41:45 +00:00
],
);
}
}