-
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.
* User Does not need to login every time now * Implemented Post Impression and fine tuned sessions in the routing * Updated the getViewedUsers code * Added Prefereneces to the Sample app to mock a session * Refactor: Change dashboar_screen.dart to dashboard_screen.dart
- Loading branch information
Showing
19 changed files
with
529 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
abstract class PreferenceInterface{ | ||
Future<bool?> isLoggedIn(); | ||
Future<String?> loggedInUserId(); | ||
Future<String?> loggedInUserDisplayName(); | ||
Future<bool?> setLoggedIn( bool isLoggedIn ); | ||
Future<bool?> setLoggedInUserId(String userId); | ||
Future<bool?> setLoggedInUserDisplayName(String userDisplayName); | ||
void removeAllPreference(); | ||
} |
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,53 @@ | ||
|
||
import 'package:flutter_social_sample_app/core/preferences/preference_interface.dart'; | ||
import 'package:flutter_social_sample_app/core/preferences/shared_preferences_manager.dart'; | ||
|
||
class PreferenceInterfaceImpl extends PreferenceInterface{ | ||
|
||
SharedPreferencesManager? sharedPreferencesManager; | ||
|
||
|
||
PreferenceInterfaceImpl(){ | ||
sharedPreferencesManager = SharedPreferencesManager(); | ||
} | ||
|
||
|
||
|
||
@override | ||
Future<bool> isLoggedIn() async { | ||
return await sharedPreferencesManager?.getBool("isLoggedIn") ?? false ; | ||
} | ||
|
||
@override | ||
Future<String?> loggedInUserId() async { | ||
return await sharedPreferencesManager?.getString("loggedInUserId") ; | ||
} | ||
|
||
@override | ||
Future<bool?> setLoggedIn(bool isLoggedIn) async { | ||
return await sharedPreferencesManager?.setBool("isLoggedIn", isLoggedIn) ?? false ; | ||
} | ||
|
||
@override | ||
Future<bool?> setLoggedInUserId(String userId) async { | ||
return await sharedPreferencesManager?.setString("loggedInUserId", userId); | ||
} | ||
|
||
@override | ||
Future<String?> loggedInUserDisplayName() async { | ||
return await sharedPreferencesManager?.getString("displayName") ; | ||
} | ||
|
||
@override | ||
Future<bool?> setLoggedInUserDisplayName(String userDisplayName) async { | ||
return await sharedPreferencesManager?.setString("displayName", userDisplayName); | ||
} | ||
|
||
@override | ||
void removeAllPreference() async { | ||
sharedPreferencesManager?.remove("displayName"); | ||
sharedPreferencesManager?.remove("loggedInUserId"); | ||
sharedPreferencesManager?.remove("isLoggedIn"); | ||
} | ||
|
||
} |
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,61 @@ | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class SharedPreferencesManager { | ||
static final SharedPreferencesManager _instance = SharedPreferencesManager._internal(); | ||
|
||
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance(); | ||
SharedPreferences? prefs; | ||
|
||
factory SharedPreferencesManager() { | ||
return _instance; | ||
} | ||
|
||
|
||
SharedPreferencesManager._internal(){ | ||
setup (); | ||
} | ||
|
||
Future<void> setup () async { | ||
prefs = await _prefs; | ||
print("prefs: $prefs"); | ||
} | ||
|
||
Future<bool> setString(String key, String value) async { | ||
if(prefs == null) setup(); | ||
return await prefs!.setString(key, value); | ||
} | ||
|
||
Future<bool?> setBool(String key, bool value) async { | ||
if(prefs == null) setup(); | ||
return prefs?.setBool(key, value); | ||
} | ||
|
||
Future<bool?> setInt(String key, int value) async { | ||
if(prefs == null) setup(); | ||
return prefs?.setInt(key, value); | ||
} | ||
|
||
Future<bool> getBool(String key) async { | ||
if(prefs == null) await setup(); | ||
return prefs?.getBool(key) ?? false; | ||
} | ||
|
||
Future<String> getString(String key) async { | ||
if(prefs == null) setup(); | ||
return prefs?.getString(key) ?? ""; | ||
} | ||
|
||
Future<int> getInt(String key) async { | ||
if(prefs == null) setup(); | ||
return prefs?.getInt(key) ?? 0; | ||
} | ||
|
||
void remove(String key) async { | ||
if(prefs == null) setup(); | ||
await prefs?.remove(key); | ||
} | ||
|
||
|
||
|
||
|
||
} |
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.