Initial project
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
|
||||
import '../wiring/notification_sdk_wiring.dart';
|
||||
|
||||
/// SDK API
|
||||
abstract class NotificationSdkApi
|
||||
{
|
||||
factory NotificationSdkApi() => NotificationSdkWiring.build();
|
||||
|
||||
Future<String?> platformVersion();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
import '../../../notification_sdk.dart';
|
||||
import 'notification_sdk_core.dart';
|
||||
/// SDK API Implementation
|
||||
class NotificationSdkApiImpl implements NotificationSdkApi
|
||||
{
|
||||
final NotificationSdkCore _core;
|
||||
|
||||
NotificationSdkApiImpl({required NotificationSdkCore core}) : _core = core;
|
||||
|
||||
@override
|
||||
Future<String?> platformVersion() => _core.repo.platformVersion();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
import '../../../notification_sdk_platform_interface.dart';
|
||||
import '../../domain/repositories/notification_sdk_repository.dart';
|
||||
|
||||
class NotificationSdkCore
|
||||
{
|
||||
final NotificationSdkPlatform platform;
|
||||
final NotificationSdkRepository repo;
|
||||
|
||||
NotificationSdkCore({
|
||||
required this.platform,
|
||||
required this.repo,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
import '../../../notification_sdk.dart';
|
||||
|
||||
import '../../../notification_sdk_method_channel.dart';
|
||||
import '../../../notification_sdk_platform_interface.dart';
|
||||
|
||||
import '../../data/datasources/notification_sdk_method_channel_datasource.dart';
|
||||
import '../../data/repositories/notification_sdk_repository_impl.dart';
|
||||
|
||||
import 'notification_sdk_core.dart';
|
||||
import 'notification_sdk_api_impl.dart';
|
||||
|
||||
class NotificationSdkWiring
|
||||
{
|
||||
static NotificationSdkApi build() {
|
||||
|
||||
// platform instance(method channel)
|
||||
final platform = NotificationSdkPlatform.instance;
|
||||
if (platform is MethodChannelNotificationSdk) {
|
||||
// platform.init(); // or defer to NotificationApiImpl.init
|
||||
}
|
||||
|
||||
// data layer
|
||||
final ds = NotificationSdkMethodChannelDataSource(platform);
|
||||
final repo = NotificationSdkRepositoryImpl(ds);
|
||||
final core = NotificationSdkCore(platform: platform, repo: repo,);
|
||||
|
||||
return NotificationSdkApiImpl(core: core);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user