Init home feature add presentation layer
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class CoreBindings extends Bindings {
|
||||
|
||||
@override
|
||||
Future dependencies() async {
|
||||
await _bindingSharePreference();
|
||||
_bindingAppImagePaths();
|
||||
_bindingResponsiveManager();
|
||||
_bindingKeyboardManager();
|
||||
}
|
||||
|
||||
void _bindingAppImagePaths() {
|
||||
Get.put(ImagePaths());
|
||||
}
|
||||
|
||||
void _bindingResponsiveManager() {
|
||||
Get.put(ResponsiveUtils());
|
||||
}
|
||||
|
||||
Future _bindingSharePreference() async {
|
||||
await Get.putAsync(() async => await SharedPreferences.getInstance(), permanent: true);
|
||||
}
|
||||
|
||||
void _bindingKeyboardManager() {
|
||||
Get.put(KeyboardUtils());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/main/bindings/core/core_bindings.dart';
|
||||
import 'package:tmail_ui_user/main/bindings/network/network_bindings.dart';
|
||||
|
||||
class MainBindings extends Bindings {
|
||||
@override
|
||||
Future dependencies() async {
|
||||
await CoreBindings().dependencies();
|
||||
NetworkBindings().dependencies();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/http/http_client.dart' as JmapHttpClient;
|
||||
import 'package:tmail_ui_user/features/login/data/network/login_api.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/network/mailbox_api.dart';
|
||||
|
||||
class NetworkBindings extends Bindings {
|
||||
|
||||
@override
|
||||
void dependencies() {
|
||||
_bindingDio();
|
||||
_bindingApi();
|
||||
}
|
||||
|
||||
void _bindingBaseOption() {
|
||||
final headers = <String, dynamic>{
|
||||
HttpHeaders.acceptHeader: Constant.acceptHeaderDefault,
|
||||
HttpHeaders.contentTypeHeader: Constant.contentTypeHeaderDefault
|
||||
};
|
||||
Get.put(BaseOptions(headers: headers));
|
||||
}
|
||||
|
||||
void _bindingDio() {
|
||||
_bindingBaseOption();
|
||||
Get.put(Dio(Get.find<BaseOptions>()));
|
||||
_bindingInterceptors();
|
||||
Get.find<Dio>().interceptors.add(Get.find<DynamicUrlInterceptors>());
|
||||
Get.find<Dio>().interceptors.add(Get.find<AuthorizationInterceptors>());
|
||||
if (kDebugMode) {
|
||||
Get.find<Dio>().interceptors.add(LogInterceptor(requestBody: true));
|
||||
}
|
||||
}
|
||||
|
||||
void _bindingInterceptors() {
|
||||
Get.put(DynamicUrlInterceptors());
|
||||
Get.put(AuthorizationInterceptors());
|
||||
}
|
||||
|
||||
void _bindingApi() {
|
||||
Get.put(DioClient(Get.find<Dio>()));
|
||||
Get.put(JmapHttpClient.HttpClient(Get.find<Dio>()));
|
||||
Get.put(LoginAPI(Get.find<DioClient>()));
|
||||
Get.put(MailboxAPI(Get.find<JmapHttpClient.HttpClient>()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user