-
Notifications
You must be signed in to change notification settings - Fork 5
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
f93ce68
commit 1ec21dd
Showing
43 changed files
with
422 additions
and
432 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_workshop/feature/home/home_bloc.dart'; | ||
import 'package:flutter_workshop/feature/login/login_bloc.dart'; | ||
import 'package:flutter_workshop/model/donation/donation.dart'; | ||
import 'package:flutter_workshop/model/donation/donation_api.dart'; | ||
import 'package:flutter_workshop/model/login/login_api.dart'; | ||
import 'package:flutter_workshop/model/login/login_response.dart'; | ||
import 'package:flutter_workshop/service/session.dart'; | ||
import 'package:flutter_workshop/service/shared_preferences_storage.dart'; | ||
import 'package:flutter_workshop/util/http_event.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:provider/provider.dart'; | ||
import 'package:provider/single_child_widget.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
Future<List<SingleChildWidget>> getDependencies() async { | ||
final http.Client _httpClient = http.Client(); | ||
|
||
final SharedPreferences _sharedPreferences = | ||
await SharedPreferences.getInstance(); | ||
|
||
final SharedPreferencesStorage _sharedPreferencesStorage = | ||
SharedPreferencesStorage(_sharedPreferences); | ||
|
||
final Session _session = | ||
Session(diskStorageProvider: _sharedPreferencesStorage); | ||
|
||
await SystemChrome.setPreferredOrientations( | ||
[ | ||
DeviceOrientation.portraitUp, | ||
DeviceOrientation.portraitDown, | ||
DeviceOrientation.landscapeLeft, | ||
DeviceOrientation.landscapeRight, | ||
], | ||
); | ||
|
||
return [ | ||
Provider<LoginBloc>( | ||
create: (_) => LoginBloc( | ||
controller: StreamController<HttpEvent<LoginResponse>>.broadcast(), | ||
loginApi: LoginApi(client: _httpClient), | ||
sessionProvider: _session, | ||
), | ||
), | ||
Provider<HomeBloc?>( | ||
create: (_) => HomeBloc( | ||
controller: StreamController<List<Donation>>.broadcast(), | ||
donationApi: DonationApi(client: _httpClient), | ||
diskStorageProvider: _sharedPreferencesStorage, | ||
sessionProvider: _session, | ||
), | ||
), | ||
]; | ||
} |
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
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
Oops, something went wrong.