import 'package:hive/hive.dart'; import 'package:news/utils/constant.dart'; import 'package:news/utils/hiveBoxKeys.dart'; //AuthLocalDataSource will communicate with local database (hive) class AuthLocalDataSource { bool? checkIsAuth() { return Hive.box(authBoxKey).get(isLogInKey, defaultValue: false) ?? false; } String? getId() { return Hive.box(authBoxKey).get(userIdKey, defaultValue: "0"); } Future setId(String? id) async { Hive.box(authBoxKey).put(userIdKey, id); } String? getName() { return Hive.box(authBoxKey).get(userNameKey, defaultValue: ""); } Future setName(String? name) async { Hive.box(authBoxKey).put(userNameKey, name); } String? getEmail() { return Hive.box(authBoxKey).get(userEmailKey, defaultValue: ""); } Future setEmail(String? email) async { Hive.box(authBoxKey).put(userEmailKey, email); } String? getMobile() { return Hive.box(authBoxKey).get(userMobKey, defaultValue: ""); } Future setMobile(String? mobile) async { Hive.box(authBoxKey).put(userMobKey, mobile); } String? getType() { return Hive.box(authBoxKey).get(userTypeKey, defaultValue: ""); } Future setType(String? type) async { Hive.box(authBoxKey).put(userTypeKey, type); } String? getProfile() { return Hive.box(authBoxKey).get(userProfileKey, defaultValue: ""); } Future setProfile(String? image) async { Hive.box(authBoxKey).put(userProfileKey, image); } String? getStatus() { return Hive.box(authBoxKey).get(userStatusKey, defaultValue: ""); } Future setStatus(String? status) async { Hive.box(authBoxKey).put(userStatusKey, status); } String getJWTtoken() { return Hive.box(authBoxKey).get(jwtTokenKey, defaultValue: ""); } Future setJWTtoken(String? jwtToken) async { Hive.box(authBoxKey).put(jwtTokenKey, jwtToken); } Future changeAuthStatus(bool? authStatus) async { Hive.box(authBoxKey).put(isLogInKey, authStatus); } String? getAuthorWhatsappLink() { return Hive.box(authBoxKey).get(authorWhatsappLinkKey, defaultValue: ""); } String? getAuthorFacebookLink() { return Hive.box(authBoxKey).get(authorfacebookLinkKey, defaultValue: ""); } String? getAuthorTelegramLink() { return Hive.box(authBoxKey).get(authorTelegramLinkKey, defaultValue: ""); } String? getAuthorLinkedInLink() { return Hive.box(authBoxKey).get(authorLinkedInLinkKey, defaultValue: ""); } Future setSocialMediaLinks(String? whatsappLink, facebookLink, telegramLink, linkedInLink) async { Hive.box(authBoxKey).put(authorWhatsappLinkKey, whatsappLink); Hive.box(authBoxKey).put(authorfacebookLinkKey, facebookLink); Hive.box(authBoxKey).put(authorTelegramLinkKey, telegramLink); Hive.box(authBoxKey).put(authorLinkedInLinkKey, linkedInLink); } String getAuthorBio() { return Hive.box(authBoxKey).get(authorBioKey, defaultValue: ""); } Future setAuthorBio(String? authorBio) async { Hive.box(authBoxKey).put(authorBioKey, authorBio); } AuthorStatus getAuthorStatus() { final value = Hive.box(authBoxKey).get(authorStatusKey, defaultValue: AuthorStatus.rejected.name); return AuthorStatus.values.byName(value); } Future setAuthorStatus(AuthorStatus authorStatus) async { Hive.box(authBoxKey).put(authorStatusKey, authorStatus.name); } }