Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ apply plugin: 'kotlin-android'

android {
compileSdkVersion 29
namespace = 'atomic.financial.atomic_transact_flutter'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa

Transact.present(activity, config)

} else if (call.method == "dismissTransact") {
Transact.close(activity)
} else {
result.notImplemented()
}
Expand Down
20 changes: 17 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,23 @@ class _MyAppState extends State<MyApp> {
title: const Text('Plugin example app'),
),
body: Center(
child: ElevatedButton(
onPressed: _onButtonPressed,
child: const Text("Launch Transact"),
child: Column(
children: [
ElevatedButton(
onPressed: _onButtonPressed,
child: const Text("Launch Transact"),
),
ElevatedButton(
onPressed: () {
_onButtonPressed();
Future.delayed(Duration(seconds: 10), () {
Atomic.close();
print('close');
});
},
child: const Text("Launch And Close"),
),
],
),
),
),
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/SwiftAtomicTransactFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class SwiftAtomicTransactFlutterPlugin: NSObject, FlutterPlugin {
}
}
break;
case "dismissTransact":
Atomic.dismissTransact()

default:
result(FlutterMethodNotImplemented)
Expand Down
17 changes: 9 additions & 8 deletions lib/platform_interface/atomic_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class AtomicMethodChannel extends AtomicPlatformInterface {
);
}

@override
Future<void> dismissTransact() async {
await _channel.invokeMethod('dismissTransact');
}

/// Handles receiving messages on the [MethodChannel]
Future<dynamic> _onMethodCall(MethodCall call) async {
switch (call.method) {
Expand All @@ -46,21 +51,17 @@ class AtomicMethodChannel extends AtomicPlatformInterface {
final type = AtomicTransactCompletionType.values.byName(typeName);

final responseData = call.arguments['response'];
final response = responseData != null
? AtomicTransactResponse.fromJson(responseData)
: null;
final response =
responseData != null ? AtomicTransactResponse.fromJson(responseData) : null;

final errorName = call.arguments['error'];
final error = errorName != null
? AtomicTransactError.values.byName(errorName)
: null;
final error = errorName != null ? AtomicTransactError.values.byName(errorName) : null;

onCompletion?.call(type, response, error);
break;

default:
throw MissingPluginException(
'${call.method} was invoked but has no handler');
throw MissingPluginException('${call.method} was invoked but has no handler');
}
}
}
4 changes: 4 additions & 0 deletions lib/platform_interface/atomic_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ abstract class AtomicPlatformInterface extends PlatformInterface {
}) async {
throw UnimplementedError('presentTransact() has not been implemented.');
}

Future<void> dismissTransact() async {
throw UnimplementedError('dismissTransact() has not been implemented.');
}
}
7 changes: 5 additions & 2 deletions lib/src/atomic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import 'types.dart';
import 'config.dart';

class Atomic {
static AtomicPlatformInterface get _platform =>
AtomicPlatformInterface.instance;
static AtomicPlatformInterface get _platform => AtomicPlatformInterface.instance;

/// Present the Atomic Transact SDK
/// - [config] Configuration of the Transact SDK.
Expand All @@ -26,4 +25,8 @@ class Atomic {
configuration: config,
);
}

static Future<void> close() async {
await _platform.dismissTransact();
}
}