Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa
})

Transact.presentAction(activity, config)
} else if (call.method == "dismissTransact") {
Transact.close(activity)
} else if (call.method == "hideTransact") {
Transact.hideTransact(activity)
Comment thread
sean-hill marked this conversation as resolved.
} else {
result.notImplemented()
}
Expand Down
18 changes: 18 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ class _MyAppState extends State<MyApp> {
onPressed: _onActionButtonPressed,
child: const Text("Launch Action"),
),
ElevatedButton(
onPressed: () {
_onButtonPressed();
Future.delayed(Duration(seconds: 10), () {
Atomic.close();
});
},
child: const Text("Launch And Close"),
),
ElevatedButton(
onPressed: () {
_onButtonPressed();
Future.delayed(Duration(seconds: 10), () {
Atomic.hide();
});
},
child: const Text("Launch And Hide"),
),
],
),
),
Expand Down
7 changes: 6 additions & 1 deletion ios/Classes/SwiftAtomicTransactFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ public class SwiftAtomicTransactFlutterPlugin: NSObject, FlutterPlugin {
} else {
result(FlutterError(code: "PlatformError", message: "No keyWindow found", details: nil))
}
break;
break;
case "dismissTransact":
Atomic.dismissTransact()
case "hideTransact":
Atomic.hideTransact()

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

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

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

/// Handles receiving messages on the [MethodChannel]
Future<dynamic> _onMethodCall(MethodCall call) async {
switch (call.method) {
Expand Down
8 changes: 8 additions & 0 deletions lib/platform_interface/atomic_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ abstract class AtomicPlatformInterface extends PlatformInterface {
}) async {
throw UnimplementedError('presentAction() has not been implemented.');
}

Future<void> dismissTransact() async {
throw UnimplementedError('dismissTransact() has not been implemented.');
}

Future<void> hideTransact() async {
throw UnimplementedError('hideTransact() has not been implemented.');
}
}
15 changes: 14 additions & 1 deletion lib/src/atomic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ class Atomic {
_platform.onCompletion = onCompletion;

await _platform.presentAction(
id: id, environment: environment, theme: theme, presentationStyleIOS: presentationStyleIOS);
id: id,
environment: environment,
theme: theme,
presentationStyleIOS: presentationStyleIOS);
}

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

static Future<void> hide() async {
_isLoading = false;
await _platform.hideTransact();
}
}