-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88171ca
commit ab08862
Showing
20 changed files
with
218 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:mental_health/features/meditation/domain/entities/mood_data.dart'; | ||
|
||
class MoodDataModel extends MoodData { | ||
MoodDataModel({ | ||
required String happy, | ||
required String neutral, | ||
required String sad, | ||
required String calm, | ||
required String relax, | ||
required String focus, | ||
}) : super( | ||
happy: happy, | ||
neutral: neutral, | ||
sad: sad, | ||
calm: calm, | ||
relax: relax, | ||
focus: focus | ||
); | ||
|
||
factory MoodDataModel.fromJson(json) { | ||
final data = jsonDecode(json); | ||
return MoodDataModel( | ||
happy: data['happy'], | ||
sad: data['sad'], | ||
neutral: data['neutral'], | ||
calm: data['calm'], | ||
relax: data['relax'], | ||
focus: data['focus'], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class MoodData { | ||
final String happy; | ||
final String neutral; | ||
final String sad; | ||
final String calm; | ||
final String relax; | ||
final String focus; | ||
|
||
MoodData({required this.happy, required this.neutral, required this.sad, required this.calm, required this.relax, required this.focus}); | ||
|
||
|
||
} |
2 changes: 2 additions & 0 deletions
2
lib/features/meditation/domain/repositories/meditation_repo.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import 'package:mental_health/features/meditation/domain/entities/dailyQuotes.dart'; | ||
import 'package:mental_health/features/meditation/domain/entities/mood_data.dart'; | ||
import 'package:mental_health/features/meditation/domain/entities/mood_msg.dart'; | ||
|
||
abstract class MeditationRepository { | ||
Future<DailyQuote> getDailyQuote(); | ||
Future<MoodMessage> getMoodMessage(String mood); | ||
Future<MoodData> getmoodData(String username); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:mental_health/features/meditation/domain/entities/mood_data.dart'; | ||
import 'package:mental_health/features/meditation/domain/repositories/meditation_repo.dart'; | ||
|
||
class GetMoodData { | ||
final MeditationRepository repository; | ||
|
||
GetMoodData({required this.repository}); | ||
|
||
Future<MoodData> call(String username) async { | ||
return await repository.getmoodData(username); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
lib/features/meditation/presentation/bloc/mood_data/mood_data_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:mental_health/features/meditation/domain/usecase/get_mood_data.dart'; | ||
import 'package:mental_health/features/meditation/presentation/bloc/mood_data/mood_data_event.dart'; | ||
import 'package:mental_health/features/meditation/presentation/bloc/mood_data/mood_data_state.dart'; | ||
|
||
class MoodDataBloc extends Bloc<MoodDataEvent, MoodDataState> { | ||
final GetMoodData getmoodData; | ||
|
||
MoodDataBloc({required this.getmoodData}) | ||
: super(MoodDataInitial()) { | ||
on<FetchMoodData>((event, emit) async { | ||
emit(MoodDataLoading()); | ||
try { | ||
final moodDatainfo = await getmoodData(event.username); | ||
emit(MoodDataLoaded(moodDatainfo: moodDatainfo)); | ||
} catch (e) { | ||
emit(MoodDataError(message: e.toString())); | ||
} | ||
}); | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
lib/features/meditation/presentation/bloc/mood_data/mood_data_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
abstract class MoodDataEvent {} | ||
|
||
class FetchMoodData extends MoodDataEvent { | ||
final String username; | ||
|
||
FetchMoodData(this.username); | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
lib/features/meditation/presentation/bloc/mood_data/mood_data_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:mental_health/features/meditation/domain/entities/mood_data.dart'; | ||
|
||
abstract class MoodDataState {} | ||
|
||
class MoodDataInitial extends MoodDataState {} | ||
|
||
class MoodDataLoading extends MoodDataState {} | ||
|
||
class MoodDataLoaded extends MoodDataState { | ||
final MoodData moodDatainfo; | ||
|
||
MoodDataLoaded({required this.moodDatainfo}); | ||
} | ||
|
||
class MoodDataError extends MoodDataState { | ||
final String message; | ||
|
||
MoodDataError({required this.message}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.