settings_page.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /// Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
  2. ///
  3. /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  4. /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  5. /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  6. /// This notice may not be removed from this file.
  7. ///
  8. import 'package:compdfkit_flutter/compdfkit.dart';
  9. import 'package:flutter/gestures.dart';
  10. import 'package:flutter/material.dart';
  11. import 'package:flutter_svg/flutter_svg.dart';
  12. import 'package:url_launcher/url_launcher.dart';
  13. import 'package:flutter_gen/gen_l10n/app_localizations.dart';
  14. class SettingsPage extends StatelessWidget {
  15. const SettingsPage({super.key});
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. appBar: AppBar(
  20. elevation: 4,
  21. excludeHeaderSemantics: true,
  22. titleSpacing: 0,
  23. title: Text(AppLocalizations.of(context)!.setting),
  24. ),
  25. body: Column(
  26. children: [
  27. Column(
  28. children: [
  29. head(context, AppLocalizations.of(context)!.sdk_information),
  30. item(context, AppLocalizations.of(context)!.versions,
  31. trailing: FutureBuilder(
  32. future: ComPDFKit.getVersionCode(),
  33. builder: (context, snap) {
  34. return Text(snap.data ?? "",
  35. style: Theme.of(context).textTheme.bodyMedium);
  36. })),
  37. head(context, AppLocalizations.of(context)!.company_information),
  38. item(context, AppLocalizations.of(context)!.compdf_official_website,
  39. onTap: () =>
  40. launchUrl(Uri.parse(AppLocalizations.of(context)!.compdf_official_website))),
  41. item(context, AppLocalizations.of(context)!.about_us,
  42. onTap: () => launchUrl(
  43. Uri.parse(AppLocalizations.of(context)!.compdf_about_us_url))),
  44. item(context, AppLocalizations.of(context)!.technical_support,
  45. onTap: () =>
  46. launchUrl(Uri.parse(AppLocalizations.of(context)!.compdf_technical_support_url))),
  47. item(context, AppLocalizations.of(context)!.contact_sales,
  48. onTap: () => launchUrl(
  49. Uri.parse(AppLocalizations.of(context)!.compdf_contact_sales_url))),
  50. item(context, AppLocalizations.of(context)!.compdf_email, onTap: () {
  51. launchUrl(Uri.parse(
  52. 'mailto:support@compdf.com?subject=${AppLocalizations.of(context)!.technical_support}'));
  53. }),
  54. ],
  55. ),
  56. Expanded(
  57. child: SafeArea(
  58. child: Padding(
  59. padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
  60. child: Column(
  61. mainAxisAlignment: MainAxisAlignment.end,
  62. children: [
  63. Text(
  64. '© 2014-2024 PDF Technologies, Inc. All Rights Reserved.',
  65. style: Theme.of(context)
  66. .textTheme
  67. .bodySmall
  68. ?.copyWith(fontSize: 11),
  69. textAlign: TextAlign.center,
  70. ),
  71. const Padding(padding: EdgeInsets.only(top: 8)),
  72. Text.rich(TextSpan(children: [
  73. TextSpan(
  74. text: AppLocalizations.of(context)!.privacy_policy,
  75. style: Theme.of(context).textTheme.bodySmall?.copyWith(
  76. fontSize: 11, color: const Color(0xFF1460F3)),
  77. recognizer: TapGestureRecognizer()
  78. ..onTap = () => launchUrl(
  79. Uri.parse(
  80. AppLocalizations.of(context)!.compdf_privacy_policy_url),
  81. )),
  82. const TextSpan(text: ' | '),
  83. TextSpan(
  84. text: AppLocalizations.of(context)!.terms_of_service,
  85. style: Theme.of(context).textTheme.bodySmall?.copyWith(
  86. fontSize: 11, color: const Color(0xFF1460F3)),
  87. recognizer: TapGestureRecognizer()
  88. ..onTap = () => launchUrl(
  89. Uri.parse(
  90. AppLocalizations.of(context)!.compdf_terms_of_service_url),
  91. )),
  92. ])),
  93. ],
  94. ),
  95. )))
  96. ],
  97. ));
  98. }
  99. Widget head(BuildContext context, String title) {
  100. return Container(
  101. width: double.infinity,
  102. padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
  103. color: Theme.of(context).brightness == Brightness.dark
  104. ? const Color(0xFF303238)
  105. : const Color(0xFFF2F2F2),
  106. child: Text(title, style: Theme.of(context).textTheme.bodySmall),
  107. );
  108. }
  109. Widget item(BuildContext context, String title,
  110. {Widget? trailing, GestureTapCallback? onTap}) {
  111. return ListTile(
  112. onTap: onTap,
  113. title: Text(title, style: Theme.of(context).textTheme.bodyMedium),
  114. trailing: trailing ??
  115. SvgPicture.asset(
  116. 'images/ic_syasarrow.svg',
  117. color: Theme.of(context).colorScheme.onPrimary,
  118. ));
  119. }
  120. }