-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from ia-toki/fix-shuffle
Fix shuffle and main page
- Loading branch information
Showing
9 changed files
with
76 additions
and
13 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,28 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
import '../../../../services/firebase_service.dart'; | ||
|
||
part 'main_state.dart'; | ||
|
||
class MainCubit extends Cubit<MainState> { | ||
MainCubit() : super(MainInitial()); | ||
|
||
Future<void> fetchUser() async { | ||
try { | ||
final userSnapshot = await FirebaseFirestore.instance | ||
.collection('registered_user') | ||
.doc(FirebaseService.auth().currentUser?.uid) | ||
.get(); | ||
final userData = userSnapshot.data(); | ||
if (userData != null) { | ||
emit(MainSuccess(userData)); | ||
} else { | ||
throw Exception('User Data cannot be extracted'); | ||
} | ||
} catch (e) { | ||
emit(MainFailed(e.toString())); | ||
} | ||
} | ||
} |
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,25 @@ | ||
part of 'main_cubit.dart'; | ||
|
||
@immutable | ||
abstract class MainState {} | ||
|
||
class MainInitial extends MainState {} | ||
|
||
class MainSuccess extends MainState { | ||
final Map<String, dynamic> userData; | ||
|
||
MainSuccess( | ||
this.userData, | ||
); | ||
|
||
@override | ||
List<Object> get props => [userData]; | ||
} | ||
|
||
class MainFailed extends MainState { | ||
final String error; | ||
|
||
MainFailed(this.error); | ||
@override | ||
List<Object> get props => [error]; | ||
} |
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