| 1 | import 'package:cake_wallet/generated/i18n.dart'; |
| 2 | import 'package:cake_wallet/routes.dart'; |
| 3 | import 'package:cake_wallet/src/screens/base_page.dart'; |
| 4 | import 'package:cake_wallet/src/widgets/cake_image_widget.dart'; |
| 5 | import 'package:cake_wallet/src/widgets/option_tile.dart'; |
| 6 | import 'package:cake_wallet/utils/device_info.dart'; |
| 7 | import 'package:cake_wallet/view_model/support_view_model.dart'; |
| 8 | import 'package:flutter/material.dart'; |
| 9 | import 'package:flutter_svg/svg.dart'; |
| 10 | import 'package:url_launcher/url_launcher.dart'; |
| 11 | |
| 12 | class SupportPage extends BasePage { |
| 13 | SupportPage(this.supportViewModel); |
| 14 | |
| 15 | final SupportViewModel supportViewModel; |
| 16 | |
| 17 | @override |
| 18 | String get title => S.current.settings_support; |
| 19 | |
| 20 | @override |
| 21 | AppBarStyle get appBarStyle => AppBarStyle.regular; |
| 22 | |
| 23 | String get _imageSupportChat => currentTheme.isDark |
| 24 | ? 'assets/new-ui/icons/support_chat_dark.svg' |
| 25 | : 'assets/new-ui/icons/support_chat.svg'; |
| 26 | |
| 27 | String get _imageSupportDocs => currentTheme.isDark |
| 28 | ? 'assets/new-ui/icons/support_docs_dark.svg' |
| 29 | : 'assets/new-ui/icons/support_docs.svg'; |
| 30 | |
| 31 | String get _imageSupportLinks => currentTheme.isDark |
| 32 | ? 'assets/new-ui/icons/support_links_dark.svg' |
| 33 | : 'assets/new-ui/icons/support_links.svg'; |
| 34 | |
| 35 | @override |
| 36 | Widget body(BuildContext context) => Center( |
| 37 | child: Container( |
| 38 | padding: const EdgeInsets.only(left: 16, right: 16, top: 16), |
| 39 | child: Column( |
| 40 | spacing: 16, |
| 41 | children: [ |
| 42 | OptionTile( |
| 43 | image: CakeImageWidget(imageUrl: _imageSupportChat, width: 55, height: 55), |
| 44 | title: S.of(context).support_title_live_chat, |
| 45 | description: S.of(context).support_description_live_chat, |
| 46 | onPressed: () => _onPressedSupportChat(context), |
| 47 | ), |
| 48 | OptionTile( |
| 49 | image: CakeImageWidget(imageUrl: _imageSupportDocs, width: 55, height: 55), |
| 50 | title: S.of(context).support_title_guides, |
| 51 | description: S.of(context).support_description_guides, |
| 52 | onPressed: () => _launchUrl(supportViewModel.docsUrl), |
| 53 | ), |
| 54 | OptionTile( |
| 55 | image: CakeImageWidget(imageUrl: _imageSupportLinks, width: 55, height: 55), |
| 56 | title: S.of(context).support_title_other_links, |
| 57 | description: S.of(context).support_description_other_links, |
| 58 | onPressed: () => Navigator.pushNamed(context, Routes.supportOtherLinks), |
| 59 | ), |
| 60 | ], |
| 61 | ), |
| 62 | ), |
| 63 | ); |
| 64 | |
| 65 | void _onPressedSupportChat(BuildContext context) { |
| 66 | if (DeviceInfo.instance.isDesktop) { |
| 67 | _launchUrl(supportViewModel.fetchUrl()); |
| 68 | } else { |
| 69 | Navigator.of(context, rootNavigator: true).pushNamed(Routes.supportLiveChat); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | void _launchUrl(String url) async { |
| 74 | try { |
| 75 | await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication); |
| 76 | } catch (e) {} |
| 77 | } |
| 78 | } |