diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f9cd839..fd3618f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,27 @@ jobs: with: channel: 'stable' + # Cache Flutter dependencies + - name: Cache Flutter packages + uses: actions/cache@v3 + with: + path: | + ~/.pub-cache + key: flutter-packages-${{ runner.os }}-${{ hashFiles('pubspec.yaml') }} + restore-keys: | + flutter-packages-${{ runner.os }}- + + # Cache Gradle dependencies + - name: Cache Gradle + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle-${{ runner.os }}- + - name: Setup Keystore run: | echo "${{ secrets.KEYSTORE }}" | base64 --decode >android/app/mykey.jks @@ -39,15 +60,16 @@ jobs: uses: ncipollo/release-action@v1 with: artifacts: "build/app/outputs/apk/release/*" - tag: v2.0.9 + tag: v2.0.9.1 token: ${{ secrets.TOKEN }} - name: "beta-v2.0.9" + name: "beta-v2.0.9.1" body: | - ## What's New in v2.0.9 + ## What's New in v2.0.9.1 + - **Redis Cloud Implementation and Fetching in Beta Phase** - **Structure of Redis added to Clean Architecture - **Added Redis-base to support syncfusion** - **Fixed Performance and Responsiveness Issues by Improvised BLoC Structure. - **New Feature**: Implemented Syncfusion and Redis for low latency. - + ### Known Issues are Resolved - Looking for vulnerabilities before Redis Full-Integration. diff --git a/README.md b/README.md index 9b8ed04..386f0ee 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build Status - Version + Version

@@ -17,8 +17,9 @@ **APP STATUS** : ALL CORE FUNCTIONALITIES WORKING (Deployed NodeJs & Postgresql on Render) -## What's New in v2.0.9 +## What's New in v2.0.9.1 (Beta Trial Phase for Redis) + - **Redis Cloud Implementation and Fetching in Beta Phase** - **Structure of Redis added to Clean Architecture - **Added Redis-base to support syncfusion** - **Fixed Performance and Responsiveness Issues by Improvised BLoC Structure. diff --git a/lib/features/meditation/data/model/mood_data_model.dart b/lib/features/meditation/data/model/mood_data_model.dart index f29bd06..6f2fa03 100644 --- a/lib/features/meditation/data/model/mood_data_model.dart +++ b/lib/features/meditation/data/model/mood_data_model.dart @@ -19,15 +19,14 @@ class MoodDataModel extends MoodData { focus: focus ); - factory MoodDataModel.fromJson(json) { - final data = jsonDecode(json); + factory MoodDataModel.fromJson(Map json) { return MoodDataModel( - happy: data['happy'], - sad: data['sad'], - neutral: data['neutral'], - calm: data['calm'], - relax: data['relax'], - focus: data['focus'], + happy: json['happy'].toString(), + sad: json['sad'].toString(), + neutral: json['neutral'].toString(), + calm: json['calm'].toString(), + relax: json['relax'].toString(), + focus: json['focus'].toString() ); } } diff --git a/lib/features/meditation/data/sources/meditation_remote_source.dart b/lib/features/meditation/data/sources/meditation_remote_source.dart index be9ba10..b54faa9 100644 --- a/lib/features/meditation/data/sources/meditation_remote_source.dart +++ b/lib/features/meditation/data/sources/meditation_remote_source.dart @@ -46,7 +46,7 @@ class MeditationRemoteDataSourceImpl implements MeditaionRemoteDataSource { @override Future getmoodData(String username)async{ final response = await client.get(Uri.parse( - 'http://192.168.29.6:6000/user/$username' + 'https://mindful-app-47s6.onrender.com/user/$username' )); if (response.statusCode==200){ diff --git a/lib/features/meditation/presentation/pages/meditation_page.dart b/lib/features/meditation/presentation/pages/meditation_page.dart index 8cf855d..bedc1fc 100644 --- a/lib/features/meditation/presentation/pages/meditation_page.dart +++ b/lib/features/meditation/presentation/pages/meditation_page.dart @@ -9,6 +9,8 @@ import 'package:mental_health/features/auth/domain/entities/auth/googleapisignin import 'package:mental_health/features/meditation/presentation/bloc/dailyQuote/daily_quote_bloc.dart'; import 'package:mental_health/features/meditation/presentation/bloc/dailyQuote/daily_quote_event.dart'; import 'package:mental_health/features/meditation/presentation/bloc/dailyQuote/daily_quote_state.dart'; +import 'package:mental_health/features/meditation/presentation/bloc/mood_data/mood_data_bloc.dart'; +import 'package:mental_health/features/meditation/presentation/bloc/mood_data/mood_data_state.dart'; import 'package:mental_health/features/meditation/presentation/bloc/mood_message/mood_message_bloc.dart'; import 'package:mental_health/features/meditation/presentation/bloc/mood_message/mood_message_event.dart'; import 'package:mental_health/features/meditation/presentation/bloc/mood_message/mood_message_state.dart'; @@ -42,54 +44,6 @@ class _MeditationPageState extends State { TooltipBehavior(enable: true, format: 'point.x : point.y%'); __tooltipBehavior = _tooltipBehavior; - __chartData = [ - ChartSampleData( - x: 'Mon', y: 16, secondSeriesYValue: 8, thirdSeriesYValue: 13), - ChartSampleData( - x: 'Tue', y: 8, secondSeriesYValue: 10, thirdSeriesYValue: 7), - ChartSampleData( - x: 'Wed', y: 12, secondSeriesYValue: 10, thirdSeriesYValue: 5), - ChartSampleData( - x: 'Thurs', y: 4, secondSeriesYValue: 8, thirdSeriesYValue: 14), - ChartSampleData( - x: 'Fri', y: 8, secondSeriesYValue: 5, thirdSeriesYValue: 4), - ChartSampleData( - x: 'Sat', y: 3, secondSeriesYValue: 3, thirdSeriesYValue: 6), - ]; - - dataSources = [ - ChartSampleData( - x: 'Happy', - y: 62.70, - text: '10%', - pointColor: const Color.fromRGBO(69, 186, 161, 1.0)), - ChartSampleData( - x: 'Neutral', - y: 29.20, - text: '10%', - pointColor: const Color.fromRGBO(230, 135, 111, 1.0)), - ChartSampleData( - x: 'Sad', - y: 85.20, - text: '100%', - pointColor: const Color.fromRGBO(145, 132, 202, 1.0)), - ChartSampleData( - x: 'Calm', - y: 85.20, - text: '100%', - pointColor: const Color.fromRGBO(145, 132, 202, 1.0)), - ChartSampleData( - x: 'Relax', - y: 85.20, - text: '100%', - pointColor: const Color.fromRGBO(145, 132, 202, 1.0)), - ChartSampleData( - x: 'Focus', - y: 45.70, - text: '100%', - pointColor: const Color.fromRGBO(235, 96, 143, 1.0)) - ]; - _annotationSources = [ CircularChartAnnotation( widget: ClipRRect( @@ -800,7 +754,65 @@ class _MeditationPageState extends State { textAlign: TextAlign.center, ), //graph - _buildColumnChart() + BlocBuilder(builder: (context,state){ + if (state is MoodDataLoaded){ + __chartData = [ + ChartSampleData(x: 'Mon', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + ChartSampleData(x: 'Tue', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + ChartSampleData(x: 'Wed', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + ChartSampleData(x: 'Thurs', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + ChartSampleData(x: 'Fri', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + ChartSampleData(x: 'Sat', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + ChartSampleData(x: 'Sun', y: num.parse(state.moodDatainfo.happy), secondSeriesYValue: num.parse(state.moodDatainfo.neutral), thirdSeriesYValue: num.parse(state.moodDatainfo.calm)), + + ]; + + num total = num.parse(state.moodDatainfo.happy)+num.parse(state.moodDatainfo.neutral)+num.parse(state.moodDatainfo.sad)+num.parse(state.moodDatainfo.calm)+num.parse(state.moodDatainfo.relax)+num.parse(state.moodDatainfo.focus); + dataSources = [ + ChartSampleData( + x: 'Happy', + y: num.parse(state.moodDatainfo.happy)/total, + text: '10%', + pointColor: const Color.fromRGBO(69, 186, 161, 1.0)), + ChartSampleData( + x: 'Neutral', + y: num.parse(state.moodDatainfo.neutral)/total, + text: '10%', + pointColor: const Color.fromRGBO(230, 135, 111, 1.0)), + ChartSampleData( + x: 'Sad', + y:num.parse(state.moodDatainfo.sad)/total, + text: '100%', + pointColor: const Color.fromRGBO(145, 132, 202, 1.0)), + ChartSampleData( + x: 'Calm', + y: num.parse(state.moodDatainfo.calm)/total, + text: '100%', + pointColor: const Color.fromRGBO(145, 132, 202, 1.0)), + ChartSampleData( + x: 'Relax', + y: num.parse(state.moodDatainfo.relax)/total, + text: '100%', + pointColor: const Color.fromRGBO(145, 132, 202, 1.0)), + ChartSampleData( + x: 'Focus', + y: num.parse(state.moodDatainfo.focus)/total, + text: '100%', + pointColor: const Color.fromRGBO(235, 96, 143, 1.0)) + ]; + return _buildColumnChart(); + } + if (state is MoodDataLoading){ + return const Text("loading"); + } + + if (state is MoodDataError){ + return Text(state.message); + } + return Container(); + + }) + ], ), ), @@ -852,6 +864,7 @@ class _MeditationPageState extends State { return Container(); }, ), + ], ), ), diff --git a/lib/main.dart b/lib/main.dart index 6008ac2..cb284f9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -56,20 +56,27 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { final mybox = Hive.box('lastlogin'); + final idval; + bool google = mybox.get('google').toString() == 'true'; + if (google) { + idval = "${GoogleSignInApi.details()?.email}-google"; + }else{ + idval = FirebaseAuth.instance.currentUser?.email.toString(); + } return MultiBlocProvider( providers: [ BlocProvider(create: (_) => NavBloc()), BlocProvider(create: (context) => di.sl()..add(FetchSongs())), BlocProvider(create: (context) => di.sl()..add(FetchDailyQuote())), BlocProvider(create: (context) => di.sl()), - BlocProvider(create: (context) => di.sl()..add(FetchMoodData("aryasingh8405@gmail.com-google"))), + BlocProvider(create: (context) => di.sl()..add(FetchMoodData(idval))), ], child: MaterialApp( debugShowCheckedModeBanner: false, title: 'Mental Health', theme: AppTheme.lightTheme, home: (FirebaseAuth.instance.currentUser == null) - ? mybox.get('google').toString() == 'true' + ? google ? const inPage() : const Onboarding() : HomePage(),