From 020791ed31a5a6e1f5324cfe6418ef59a8698fa7 Mon Sep 17 00:00:00 2001 From: pyrossh Date: Thu, 24 Aug 2023 19:47:25 +0530 Subject: [PATCH] improve stuff --- assets/{ => md}/about-us.md | 4 +- assets/{ => md}/privacy-policy.md | 0 lib/providers/app_model.dart | 11 +- lib/screens/privacy_policy_screen.dart | 34 ----- lib/theme.dart | 13 +- .../scaffold_markdown.dart} | 18 ++- lib/widgets/settings_sheet.dart | 85 +++++-------- lib/widgets/sliver_tile_grid.dart | 2 +- lib/widgets/verses_view.dart | 118 +++++++++--------- macos/Podfile.lock | 12 ++ macos/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- pubspec.lock | 8 -- pubspec.yaml | 4 +- 14 files changed, 138 insertions(+), 175 deletions(-) rename assets/{ => md}/about-us.md (74%) rename assets/{ => md}/privacy-policy.md (100%) delete mode 100644 lib/screens/privacy_policy_screen.dart rename lib/{screens/about_us_screen.dart => widgets/scaffold_markdown.dart} (56%) diff --git a/assets/about-us.md b/assets/md/about-us.md similarity index 74% rename from assets/about-us.md rename to assets/md/about-us.md index 306ca413..9799b77f 100644 --- a/assets/about-us.md +++ b/assets/md/about-us.md @@ -10,7 +10,7 @@ The word was given freely to all and is expected to be free even after processin marketplace to take our God's word and make it den of thieves. All the bibles used in this App are free and available in the public domain. Most of the text are sourced from -[The Word Project](https://www.wordproject.org/) and with the help and compilation done by the [Bible Database](https://github.com/godlytalias/Bible-Database) team, +[The Word Project](https://www.wordproject.org/) and compilation work done by the [Bible Database](https://github.com/godlytalias/Bible-Database) team. -I also agree and completely follow the [Copyrights declaration statement](https://www.wordproject.org/contact/new/copyrights.htm) of the Word project. +I also agree to and completely follow the [Copyrights Statement](https://www.wordproject.org/contact/new/copyrights.htm) of the Word project. diff --git a/assets/privacy-policy.md b/assets/md/privacy-policy.md similarity index 100% rename from assets/privacy-policy.md rename to assets/md/privacy-policy.md diff --git a/lib/providers/app_model.dart b/lib/providers/app_model.dart index 3b27728f..f49a868b 100644 --- a/lib/providers/app_model.dart +++ b/lib/providers/app_model.dart @@ -1,15 +1,12 @@ // import "package:firebase_performance/firebase_performance.dart"; -import "dart:ffi"; - import "package:flutter/services.dart"; import "package:flutter/material.dart"; -import "package:only_bible_app/screens/about_us_screen.dart"; import "package:only_bible_app/screens/bible_select_screen.dart"; import "package:only_bible_app/screens/book_select_screen.dart"; import "package:only_bible_app/models.dart"; -import "package:only_bible_app/screens/privacy_policy_screen.dart"; import "package:only_bible_app/widgets/actions_sheet.dart"; import "package:only_bible_app/widgets/highlight_button.dart"; +import "package:only_bible_app/widgets/scaffold_markdown.dart"; import "package:only_bible_app/widgets/note_sheet.dart"; import "package:only_bible_app/widgets/settings_sheet.dart"; import "package:package_info_plus/package_info_plus.dart"; @@ -348,7 +345,7 @@ class AppModel extends ChangeNotifier { void rateApp(BuildContext context) { if (isAndroid()) { openUrl(context, "https://play.google.com/store/apps/details?id=${packageInfo.packageName}"); - } else if (isIOS()) { + } else if (isIOS()) { openUrl(context, "https://apps.apple.com/us/app/hare-pro/id123"); } } @@ -356,7 +353,7 @@ class AppModel extends ChangeNotifier { showPrivacyPolicy(BuildContext context) { Navigator.of(context).push( createNoTransitionPageRoute( - const PrivacyPolicyScreen(), + const ScaffoldMarkdown(title: "Privacy Policy", file: "privacy-policy.md"), ), ); } @@ -364,7 +361,7 @@ class AppModel extends ChangeNotifier { showAboutUs(BuildContext context) { Navigator.of(context).push( createNoTransitionPageRoute( - const AboutUsScreen(), + const ScaffoldMarkdown(title: "About Us", file: "about-us.md"), ), ); } diff --git a/lib/screens/privacy_policy_screen.dart b/lib/screens/privacy_policy_screen.dart deleted file mode 100644 index 8869d1fc..00000000 --- a/lib/screens/privacy_policy_screen.dart +++ /dev/null @@ -1,34 +0,0 @@ -import "package:flutter/material.dart"; -import "package:flutter_markdown/flutter_markdown.dart"; -import "package:only_bible_app/utils.dart"; - -class PrivacyPolicyScreen extends StatelessWidget { - const PrivacyPolicyScreen({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text("Privacy Policy"), - ), - body: SafeArea( - child: FutureBuilder( - future: DefaultAssetBundle.of(context).loadString("assets/privacy-policy.md"), - builder: (context, snapshot) { - if (snapshot.hasData) { - return Markdown( - data: snapshot.data!, - onTapLink: (text, href, title) { - openUrl(context, href!); - }, - ); - } - return const Center( - child: CircularProgressIndicator(), - ); - }, - ), - ), - ); - } -} diff --git a/lib/theme.dart b/lib/theme.dart index 40f4757e..58352603 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -49,10 +49,10 @@ final lightTheme = ThemeData( ), hintStyle: TextStyle(color: Colors.grey), ), - appBarTheme: const AppBarTheme( - backgroundColor: Colors.white, - elevation: 0, - scrolledUnderElevation: 0, + appBarTheme: AppBarTheme( + backgroundColor: lightColorScheme.background, + elevation: 1, + foregroundColor: lightColorScheme.primary, ), bottomSheetTheme: const BottomSheetThemeData( elevation: 10, @@ -172,6 +172,11 @@ final darkTheme = lightTheme.copyWith( hoverColor: darkColorScheme.outline, dividerColor: Colors.white, shadowColor: Colors.white, + appBarTheme: AppBarTheme( + backgroundColor: darkColorScheme.background, + foregroundColor: darkColorScheme.primary, + elevation: 1, + ), bottomSheetTheme: lightTheme.bottomSheetTheme.copyWith( backgroundColor: const Color(0xFF141415), shadowColor: Colors.white, diff --git a/lib/screens/about_us_screen.dart b/lib/widgets/scaffold_markdown.dart similarity index 56% rename from lib/screens/about_us_screen.dart rename to lib/widgets/scaffold_markdown.dart index bc9db462..1bf18184 100644 --- a/lib/screens/about_us_screen.dart +++ b/lib/widgets/scaffold_markdown.dart @@ -2,21 +2,31 @@ import "package:flutter/material.dart"; import "package:flutter_markdown/flutter_markdown.dart"; import "package:only_bible_app/utils.dart"; -class AboutUsScreen extends StatelessWidget { - const AboutUsScreen({super.key}); +class ScaffoldMarkdown extends StatelessWidget { + final String title; + final String file; + + const ScaffoldMarkdown({super.key, required this.title, required this.file}); @override Widget build(BuildContext context) { return Scaffold( + backgroundColor: Theme.of(context).colorScheme.background, appBar: AppBar( - title: const Text("About Us"), + title: Text(title), ), body: SafeArea( child: FutureBuilder( - future: DefaultAssetBundle.of(context).loadString("assets/about-us.md"), + future: DefaultAssetBundle.of(context).loadString("assets/md/$file"), builder: (context, snapshot) { if (snapshot.hasData) { return Markdown( + styleSheetTheme: MarkdownStyleSheetBaseTheme.material, + styleSheet: MarkdownStyleSheet( + p: Theme.of(context).textTheme.bodyMedium, + h1: Theme.of(context).textTheme.headlineMedium, + h2: Theme.of(context).textTheme.headlineMedium, + ), data: snapshot.data!, onTapLink: (text, href, title) { openUrl(context, href!); diff --git a/lib/widgets/settings_sheet.dart b/lib/widgets/settings_sheet.dart index e1a95fd9..a1fc3bca 100644 --- a/lib/widgets/settings_sheet.dart +++ b/lib/widgets/settings_sheet.dart @@ -2,7 +2,6 @@ import "package:flutter/material.dart"; import "package:only_bible_app/providers/app_model.dart"; import "package:only_bible_app/utils.dart"; import "package:settings_ui/settings_ui.dart"; -// import "package:toggle_switch/toggle_switch.dart"; class SettingsSheet extends StatelessWidget { const SettingsSheet({super.key}); @@ -11,8 +10,8 @@ class SettingsSheet extends StatelessWidget { Widget build(BuildContext context) { final app = AppModel.of(context); final selectedBible = app.bible; - final modeIcon = app.darkMode ? Icons.dark_mode : Icons.light_mode; - final modeIconColor = app.darkMode ? const Color(0xFF59EEFF) : const Color(0xFFE5B347); + // final modeIcon = app.darkMode ? Icons.dark_mode : Icons.light_mode; + // final modeIconColor = app.darkMode ? const Color(0xFF59EEFF) : Colors.yellowAccent.shade700; final iconColor = Theme.of(context).textTheme.bodyMedium!.color; return SettingsList( contentPadding: EdgeInsets.zero, @@ -39,60 +38,38 @@ class SettingsSheet extends StatelessWidget { value: Text(selectedBible.name), onPressed: app.changeBible, ), - SettingsTile.switchTile( - onToggle: (value) { - app.toggleMode(); - }, - initialValue: app.darkMode, - leading: Icon(modeIcon, color: modeIconColor), - title: const Text("Dark mode"), + SettingsTile.navigation( + leading: const Icon(Icons.color_lens_outlined, color: Colors.pink), + title: const Text("Theme"), + trailing: ToggleButtons( + onPressed: (int index) { + app.toggleMode(); + }, + highlightColor: Colors.transparent, + borderColor: Colors.grey, + borderRadius: const BorderRadius.all(Radius.circular(25)), + selectedColor: app.darkMode ? Colors.lightBlue.shade300 : Colors.yellowAccent.shade700, + selectedBorderColor: Colors.grey, + color: Colors.grey, + fillColor: Colors.transparent, + constraints: const BoxConstraints( + minHeight: 36.0, + minWidth: 50.0, + ), + isSelected: [!app.darkMode, app.darkMode], + children: const [ + Icon(Icons.light_mode), + Icon(Icons.dark_mode), + ], + ), ), - // SettingsTile.navigation( - // leading: Icon(Icons.color_lens_outlined, color: Colors.pink), - // title: const Text("Theme"), - // trailing: ToggleSwitch( - // // minWidth: 50.0, - // // minHeight: 50.0, - // initialLabelIndex: app.darkMode ? 1 : 0, - // cornerRadius: 20.0, - // borderWidth: 1, - // dividerColor: Colors.black, - // dividerMargin: 1, - // borderColor: [Color(0xFFE9E9EA), Color(0xFFE9E9EA)], - // activeFgColor: modeIconColor, - // inactiveBgColor: Color(0xFFEAEAEB), - // inactiveFgColor: Colors.grey, - // activeBgColors: [[Colors.white, Colors.white], [Color(0xFF39393D), Color(0xFF39393D)]], - // totalSwitches: 2, - // icons: const [ - // Icons.light_mode, - // Icons.dark_mode, - // ], - // iconSize: 50.0, - // animate: true, - // onToggle: (index) { - // app.toggleMode(); - // }, - // ), - // ), SettingsTile.switchTile( onToggle: (value) { app.toggleBold(); }, initialValue: app.fontBold, leading: Icon(Icons.format_bold, color: iconColor), - title: const Text("Font Weight"), - // trailing: ToggleSwitch( - // minHeight: 35, - // minWidth: 70, - // cornerRadius: 20.0, - // initialLabelIndex: 0, - // totalSwitches: 2, - // labels: const ["Normal", "Bold"], - // onToggle: (index) { - // print('switched to: $index'); - // }, - // ), + title: const Text("Font Bold"), ), SettingsTile( title: const Text("Increase font size"), @@ -117,23 +94,23 @@ class SettingsSheet extends StatelessWidget { margin: const EdgeInsetsDirectional.symmetric(horizontal: 20, vertical: 20), tiles: [ SettingsTile.navigation( - leading: const Icon(Icons.policy_outlined, color: Colors.grey), + leading: const Icon(Icons.policy_outlined, color: Colors.brown), title: const Text("Privacy Policy"), onPressed: app.showPrivacyPolicy, ), SettingsTile.navigation( - leading: const Icon(Icons.share_outlined, color: Colors.grey), + leading: const Icon(Icons.share_outlined, color: Colors.blueAccent), title: const Text("Share the app"), onPressed: app.shareAppLink, ), if (!isDesktop()) // TODO: mabe support OSx if we release in that store SettingsTile.navigation( - leading: const Icon(Icons.star_border_outlined, color: Colors.grey), + leading: Icon(Icons.star, color: Colors.yellowAccent.shade700), title: const Text("Rate the app"), onPressed: app.rateApp, ), SettingsTile.navigation( - leading: const Icon(Icons.info_outline, color: Colors.grey), + leading: const Icon(Icons.info_outline, color: Colors.black), title: const Text("About us"), onPressed: app.showAboutUs, ), diff --git a/lib/widgets/sliver_tile_grid.dart b/lib/widgets/sliver_tile_grid.dart index 128764d8..3e0231d9 100644 --- a/lib/widgets/sliver_tile_grid.dart +++ b/lib/widgets/sliver_tile_grid.dart @@ -17,7 +17,7 @@ enum ListType { double childAspectRatio(bool isDesktop) { switch (this) { case ListType.small: - return isDesktop ? 2.33 : 1.4; + return isDesktop ? 1.8 : 1.4; case ListType.large: return isDesktop ? 5 : 4; } diff --git a/lib/widgets/verses_view.dart b/lib/widgets/verses_view.dart index c203cca9..217aeb8d 100644 --- a/lib/widgets/verses_view.dart +++ b/lib/widgets/verses_view.dart @@ -26,72 +26,78 @@ class VersesView extends StatelessWidget { child: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ // const Padding( // padding: EdgeInsets.only(top: 0), // ), - Text.rich( - // scrollPhysics: const BouncingScrollPhysics(), - // contextMenuBuilder: null, - textScaleFactor: app.textScaleFactor, - // onSelectionChanged: (selection, _) { - // }, - TextSpan( - style: app.fontBold - ? textStyle.copyWith( - fontWeight: FontWeight.w500, - ) - : textStyle, - // recognizer: TapAndPanGestureRecognizer()..onDragEnd = (e) => print("Hello"), - children: chapter.verses - .map( - (v) => [ - WidgetSpan( - child: Transform.translate( - offset: const Offset(0, -2), - child: Text("${v.index + 1} ", style: Theme.of(context).textTheme.labelMedium), - ), + Align( + alignment: Alignment.centerLeft, + child: Text.rich( + // scrollPhysics: const BouncingScrollPhysics(), + // contextMenuBuilder: null, + textScaleFactor: app.textScaleFactor, + textAlign: TextAlign.left, + // onSelectionChanged: (selection, _) { + // }, + TextSpan( + style: app.fontBold + ? textStyle.copyWith( + fontWeight: FontWeight.w500, + ) + : textStyle, + // recognizer: TapAndPanGestureRecognizer()..onDragEnd = (e) => print("Hello"), + children: chapter.verses + .map( + (v) => [ + WidgetSpan( + child: Transform.translate( + offset: const Offset(0, -2), + child: Text("${v.index + 1} ", style: Theme.of(context).textTheme.labelMedium), ), - if (app.hasNote(v)) - WidgetSpan( - child: Padding( - padding: const EdgeInsets.only(left: 3, right: 3), - child: GestureDetector( - onTap: () { - app.showNoteField(context, v); - }, - child: const Icon( - Icons.sticky_note_2_outlined, - size: 18, - color: Colors.blue, - ), + ), + if (app.hasNote(v)) + WidgetSpan( + child: Padding( + padding: const EdgeInsets.only(left: 3, right: 3), + child: GestureDetector( + onTap: () { + app.showNoteField(context, v); + }, + child: const Icon( + Icons.sticky_note_2_outlined, + size: 18, + color: Colors.blue, ), ), ), - TextSpan( - text: "${v.text}\n", - style: context.watch().isVerseSelected(v) - ? TextStyle( - backgroundColor: app.darkMode ? Colors.grey.shade800 : Colors.grey.shade200, - ) - : TextStyle( - backgroundColor: app.getHighlight(v) ?? Theme.of(context).colorScheme.background, - ), - recognizer: TapGestureRecognizer() - ..onTap = () { - model.onVerseSelected(context, v); - // AppModel.ofEvent(context).showHighlightMenu(context, v, details.globalPosition); - }, ), - const WidgetSpan( - child: Padding( - padding: EdgeInsets.only(top: 16, bottom: 16), - ), + TextSpan( + text: "${v.text}\n", + style: context.watch().isVerseSelected(v) + ? TextStyle( + backgroundColor: app.darkMode ? Colors.grey.shade800 : Colors.grey.shade200, + ) + : TextStyle( + backgroundColor: app.getHighlight(v) ?? Theme.of(context).colorScheme.background, + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + model.onVerseSelected(context, v); + // AppModel.ofEvent(context).showHighlightMenu(context, v, details.globalPosition); + }, + ), + const WidgetSpan( + child: Padding( + padding: EdgeInsets.only(top: 16, bottom: 16), ), - ], - ) - .expand((element) => element) - .toList(), + ), + ], + ) + .expand((element) => element) + .toList(), + ), ), ), Padding( diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 704df9b5..47d71c28 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -79,6 +79,8 @@ PODS: - nanopb/encode (= 2.30909.0) - nanopb/decode (2.30909.0) - nanopb/encode (2.30909.0) + - package_info_plus (0.0.1): + - FlutterMacOS - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS @@ -90,6 +92,8 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS DEPENDENCIES: - audio_session (from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos`) @@ -98,9 +102,11 @@ DEPENDENCIES: - firebase_storage (from `Flutter/ephemeral/.symlinks/plugins/firebase_storage/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`) + - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) SPEC REPOS: trunk: @@ -134,12 +140,16 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral just_audio: :path: Flutter/ephemeral/.symlinks/plugins/just_audio/macos + package_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos path_provider_foundation: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin share_plus: :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: audio_session: dea1f41890dbf1718f04a56f1d6150fd50039b72 @@ -162,11 +172,13 @@ SPEC CHECKSUMS: GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72 just_audio: 9b67ca7b97c61cfc9784ea23cd8cc55eb226d489 nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431 + package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265 share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 + url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 68e5367f..f431fc39 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -262,7 +262,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3855f097..a1a39288 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@