diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 9035c89..4a14f82 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -201,7 +201,7 @@ }, { "name": "intl", - "rootUri": "file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.18.1", + "rootUri": "file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.17.0", "packageUri": "lib/", "languageVersion": "2.12" }, @@ -379,12 +379,6 @@ "packageUri": "lib/", "languageVersion": "2.18" }, - { - "name": "timeago", - "rootUri": "file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/timeago-3.6.1", - "packageUri": "lib/", - "languageVersion": "2.12" - }, { "name": "timing", "rootUri": "file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/timing-1.0.1", @@ -428,7 +422,7 @@ "languageVersion": "2.17" } ], - "generated": "2024-04-17T13:38:49.333490Z", + "generated": "2024-04-18T09:34:08.334722Z", "generator": "pub", "generatorVersion": "2.19.6" } diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset index 88228a5..6f914e0 100644 --- a/.dart_tool/package_config_subset +++ b/.dart_tool/package_config_subset @@ -140,8 +140,8 @@ file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/http_parser-4.0.2/ file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/http_parser-4.0.2/lib/ intl 2.12 -file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.18.1/ -file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.18.1/lib/ +file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.17.0/ +file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.17.0/lib/ io 2.12 file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/io-1.0.4/ @@ -254,10 +254,6 @@ test_api 2.18 file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.4.16/ file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.4.16/lib/ -timeago -2.12 -file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/timeago-3.6.1/ -file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/timeago-3.6.1/lib/ timing 2.14 file:///C:/Users/WDI-/AppData/Local/Pub/Cache/hosted/pub.dev/timing-1.0.1/ diff --git a/gsf/lib/api/ratingController.dart b/gsf/lib/api/ratingController.dart new file mode 100644 index 0000000..f50cbd8 --- /dev/null +++ b/gsf/lib/api/ratingController.dart @@ -0,0 +1,39 @@ +import 'package:get/get.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +// loadRatingFromPrefs(int val) async { +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// prefs.getInt('rating') ?? 0; +// } + +class RatingController extends GetxController { + var rating = 0; + + @override + void onInit() { + super.onInit(); + loadRatingFromPrefs(); + } + + Future loadRatingFromPrefs() async { + try { + SharedPreferences prefs = await SharedPreferences.getInstance(); + rating = prefs.getInt('rating') ?? 0; + update(); + } catch (error) { + print('Error loading rating from SharedPreferences: $error'); + rating = 0; + } + } + + Future updateRating(int newRating) async { + try { + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.setInt('rating', newRating); + rating = newRating; + update(); + } catch (error) { + print('Error updating rating in SharedPreferences: $error'); + } + } +} diff --git a/gsf/lib/main.dart b/gsf/lib/main.dart index d87e352..4167800 100644 --- a/gsf/lib/main.dart +++ b/gsf/lib/main.dart @@ -22,6 +22,7 @@ import 'package:onesignal_flutter/onesignal_flutter.dart'; import 'package:pedometer/pedometer.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'api/ratingController.dart'; import 'views/pages/intro/get_started.dart'; import 'views/short_video_player/svp_lib/injection.dart'; @@ -96,6 +97,8 @@ class MyApp extends StatefulWidget { State createState() => _MyAppState(); } +final RatingController ratingController = Get.put(RatingController()); + class _MyAppState extends State { //pedometer module variables late Stream _stepCountStream; @@ -110,6 +113,7 @@ class _MyAppState extends State { void initState() { super.initState(); // initShortClipLinks(); + ratingController.loadRatingFromPrefs(); LocalStorage.init(); IcBluetoothSdk.instance.initSDK(ICDeviceManagerConfig()); checkLocationStatus(); diff --git a/gsf/lib/views/pages/settings/ratings.dart b/gsf/lib/views/pages/settings/ratings.dart index d07a624..2c5da43 100644 --- a/gsf/lib/views/pages/settings/ratings.dart +++ b/gsf/lib/views/pages/settings/ratings.dart @@ -6,10 +6,12 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:get/get.dart'; import '../../../api/ResponseManager.dart'; +import '../../../api/ratingController.dart'; import '../../../repository/services/rate_usServices.dart'; import '../../components/appbar.dart'; import '../../components/btn.dart'; import '../../theme.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class Ratings extends StatefulWidget { const Ratings({Key? key}) : super(key: key); @@ -18,13 +20,20 @@ class Ratings extends StatefulWidget { State createState() => _RatingsState(); } -var _rating = 0; +// var _rating = 0; class _RatingsState extends State { + @override + void initState() { + // TODO: implement initState + super.initState(); + ratingController.loadRatingFromPrefs(); + } + final RatingController ratingController = Get.put(RatingController()); @override Widget build(BuildContext context) { _RateUsbutton() async { - if (_rating == 0) { + if (ratingController.rating == 0) { Flushbar( backgroundColor: Colors.red, message: 'Rate your experience!', @@ -33,23 +42,28 @@ class _RatingsState extends State { return; } Map updata = { - "rate_us": _rating.toString(), + "rate_us": ratingController.rating.toString(), }; final resp = await RateUsServices().postRateUs(updata); if (resp.status == ResponseStatus.SUCCESS) { // btnController.reset(); // Get.to(() => BlogMain()); - Flushbar( + Get.snackbar( + "Success !", + 'Your rating successfully added!', + duration: Duration(seconds: 1), + animationDuration: Duration(seconds: 1), + colorText: Colors.white, backgroundColor: Colors.green, - message: 'Your feedback is sent successfully!', - duration: Duration(seconds: 3), - ).show(context); - - setState(() { - _rating = 0; - }); - // _textarea.clear(); + margin: EdgeInsets.all(8), + snackStyle: SnackStyle.FLOATING, + snackPosition: SnackPosition.BOTTOM, + ); + // setState(() { + // _rating = 0; + // }); + ratingController.updateRating(ratingController.rating); } else if (resp.status == ResponseStatus.FAILED) { if (resp.data["success"] == false) { log("failed error msg is :- ${resp.data} "); @@ -101,30 +115,35 @@ class _RatingsState extends State { const SizedBox(height: 10), Padding( padding: const EdgeInsets.only(left: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: List.generate( - 5, - (index) => IconButton( - onPressed: () { - setState(() { - _rating = index + 1; - print('rating------$_rating'); - }); - }, - icon: index < _rating - ? const Icon( - Icons.star, - color: ColorConstants.kPrimaryColor, - size: 30, - ) - : const Icon( - Icons.star_border, - color: ColorConstants.kPrimaryColor, - size: 30, - ), - ), - ), + child: GetBuilder( + init: ratingController, + builder: (controller) { + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate( + 5, + (index) => IconButton( + onPressed: () { + setState(() { + ratingController.rating = index + 1; + // print('rating------$_rating'); + }); + }, + icon: index < ratingController.rating + ? const Icon( + Icons.star, + color: ColorConstants.kPrimaryColor, + size: 30, + ) + : const Icon( + Icons.star_border, + color: ColorConstants.kPrimaryColor, + size: 30, + ), + ), + ), + ); + }, ), ), const SizedBox(height: 20), diff --git a/gsf/lib/views/pages/subscription/my_subscription.dart b/gsf/lib/views/pages/subscription/my_subscription.dart index dc1e4b0..535b992 100644 --- a/gsf/lib/views/pages/subscription/my_subscription.dart +++ b/gsf/lib/views/pages/subscription/my_subscription.dart @@ -71,77 +71,77 @@ class _MySubscriptionState extends State { SizedBox( height: 60, ), - Container( - // height: 400, - width: double.infinity, - decoration: BoxDecoration( - color: !globalController.darkMode.value - ? ColorConstants.kWhite - : const Color(0xff212121), - boxShadow: [ - BoxShadow( - spreadRadius: 2, - blurRadius: 10, - color: !globalController.darkMode.value - ? ColorConstants.kBlack.withOpacity(0.3) - : ColorConstants.kWhite.withOpacity(0), - ) - ], - borderRadius: BorderRadius.circular(30), - ), - child: Padding( - padding: const EdgeInsets.all(16), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Current active plan:-', - style: TextStyle( - fontSize: 22, - color: !globalController.darkMode.value - ? ColorConstants.kBlack - : ColorConstants.kWhite, - fontFamily: 'SFPRO', - ), - ), - Text( - subscriptionObj!.result!.utmSource ?? '', - style: TextStyle( - fontSize: 22, - color: !globalController.darkMode.value - ? ColorConstants.kBlack - : ColorConstants.kWhite, - fontFamily: 'SFPRO', - ), - ), - // rowTile( - // text: - // 'Unlimited access to live virtual fitness classes led by certified trainers.'), - // SizedBox( - // height: 20, - // ), - // rowTile( - // text: - // 'Access to a library of workout videos covering various fitness levels and goals.'), - // SizedBox( - // height: 20, - // ), - // rowTile( - // text: - // 'Progress tracking to monitor your achievements and stay motivated.'), - // SizedBox( - // height: 20, - // ), - // rowTile( - // text: - // 'Basic nutrition guidance and meal planning tips.'), - // SizedBox( - // height: 20, - // ), - ], - ), - ), - ), + // Container( + // // height: 400, + // width: double.infinity, + // decoration: BoxDecoration( + // color: !globalController.darkMode.value + // ? ColorConstants.kWhite + // : const Color(0xff212121), + // boxShadow: [ + // BoxShadow( + // spreadRadius: 2, + // blurRadius: 10, + // color: !globalController.darkMode.value + // ? ColorConstants.kBlack.withOpacity(0.3) + // : ColorConstants.kWhite.withOpacity(0), + // ) + // ], + // borderRadius: BorderRadius.circular(30), + // ), + // child: Padding( + // padding: const EdgeInsets.all(16), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // 'Current active plan:-', + // style: TextStyle( + // fontSize: 22, + // color: !globalController.darkMode.value + // ? ColorConstants.kBlack + // : ColorConstants.kWhite, + // fontFamily: 'SFPRO', + // ), + // ), + // Text( + // subscriptionObj!.result!.utmSource ?? '', + // style: TextStyle( + // fontSize: 22, + // color: !globalController.darkMode.value + // ? ColorConstants.kBlack + // : ColorConstants.kWhite, + // fontFamily: 'SFPRO', + // ), + // ), + // // rowTile( + // // text: + // // 'Unlimited access to live virtual fitness classes led by certified trainers.'), + // // SizedBox( + // // height: 20, + // // ), + // // rowTile( + // // text: + // // 'Access to a library of workout videos covering various fitness levels and goals.'), + // // SizedBox( + // // height: 20, + // // ), + // // rowTile( + // // text: + // // 'Progress tracking to monitor your achievements and stay motivated.'), + // // SizedBox( + // // height: 20, + // // ), + // // rowTile( + // // text: + // // 'Basic nutrition guidance and meal planning tips.'), + // // SizedBox( + // // height: 20, + // // ), + // ], + // ), + // ), + // ), SizedBox( height: 25, ), diff --git a/pubspec.lock b/pubspec.lock index b3f5bee..ca2d65d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -263,10 +263,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.17.0" io: dependency: transitive description: @@ -496,14 +496,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.16" - timeago: - dependency: "direct main" - description: - name: timeago - sha256: d3204eb4c788214883380253da7f23485320a58c11d145babc82ad16bf4e7764 - url: "https://pub.dev" - source: hosted - version: "3.6.1" timing: dependency: transitive description: