Skip to content

Commit 5943dcd

Browse files
feat: update callback data
1 parent a622173 commit 5943dcd

File tree

7 files changed

+30
-15
lines changed

7 files changed

+30
-15
lines changed

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>8.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -127,7 +127,7 @@
127127
97C146E61CF9000F007C117D /* Project object */ = {
128128
isa = PBXProject;
129129
attributes = {
130-
LastUpgradeCheck = 1020;
130+
LastUpgradeCheck = 1510;
131131
ORGANIZATIONNAME = "";
132132
TargetAttributes = {
133133
97C146ED1CF9000F007C117D = {
@@ -171,10 +171,12 @@
171171
/* Begin PBXShellScriptBuildPhase section */
172172
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
173173
isa = PBXShellScriptBuildPhase;
174+
alwaysOutOfDate = 1;
174175
buildActionMask = 2147483647;
175176
files = (
176177
);
177178
inputPaths = (
179+
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
178180
);
179181
name = "Thin Binary";
180182
outputPaths = (
@@ -185,6 +187,7 @@
185187
};
186188
9740EEB61CF901F6004384FC /* Run Script */ = {
187189
isa = PBXShellScriptBuildPhase;
190+
alwaysOutOfDate = 1;
188191
buildActionMask = 2147483647;
189192
files = (
190193
);
@@ -272,7 +275,7 @@
272275
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
273276
GCC_WARN_UNUSED_FUNCTION = YES;
274277
GCC_WARN_UNUSED_VARIABLE = YES;
275-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
278+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
276279
MTL_ENABLE_DEBUG_INFO = NO;
277280
SDKROOT = iphoneos;
278281
SUPPORTED_PLATFORMS = iphoneos;
@@ -346,7 +349,7 @@
346349
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
347350
GCC_WARN_UNUSED_FUNCTION = YES;
348351
GCC_WARN_UNUSED_VARIABLE = YES;
349-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
352+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
350353
MTL_ENABLE_DEBUG_INFO = YES;
351354
ONLY_ACTIVE_ARCH = YES;
352355
SDKROOT = iphoneos;
@@ -395,7 +398,7 @@
395398
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
396399
GCC_WARN_UNUSED_FUNCTION = YES;
397400
GCC_WARN_UNUSED_VARIABLE = YES;
398-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
401+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
399402
MTL_ENABLE_DEBUG_INFO = NO;
400403
SDKROOT = iphoneos;
401404
SUPPORTED_PLATFORMS = iphoneos;

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1020"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

example/ios/Runner/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@
4141
</array>
4242
<key>UIViewControllerBasedStatusBarAppearance</key>
4343
<false/>
44+
<key>CADisableMinimumFrameDurationOnPhone</key>
45+
<true/>
46+
<key>UIApplicationSupportsIndirectInputEvents</key>
47+
<true/>
4448
</dict>
4549
</plist>

example/lib/main.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class _MyHomePageState extends State<MyHomePage> {
3737
bool _recording = false;
3838
bool _exporting = false;
3939
ScreenRecorderController controller = ScreenRecorderController();
40+
4041
bool get canExport => controller.exporter.hasFrames;
4142

4243
@override
@@ -108,8 +109,7 @@ class _MyHomePageState extends State<MyHomePage> {
108109
child: ListView.builder(
109110
padding: const EdgeInsets.all(8.0),
110111
itemCount: frames.length,
111-
itemBuilder:
112-
(BuildContext context, int index) {
112+
itemBuilder: (BuildContext context, int index) {
113113
final image = frames[index].image;
114114
return SizedBox(
115115
height: 150,
@@ -135,7 +135,9 @@ class _MyHomePageState extends State<MyHomePage> {
135135
setState(() {
136136
_exporting = true;
137137
});
138-
var gif = await controller.exporter.exportGif();
138+
var gif = await controller.exporter.exportGif(percentProcess: (percent) {
139+
print('Exporting $percent');
140+
});
139141
if (gif == null) {
140142
throw Exception();
141143
}

lib/src/exporter.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ class Exporter {
4949
return bytesImages;
5050
}
5151

52-
Future<List<int>?> exportGif() async {
52+
Future<List<int>?> exportGif({ValueChanged<double>? percentProcess}) async {
5353
final frames = await exportFrames();
5454
if (frames == null) {
5555
return null;
5656
}
57-
return compute(_exportGif, DataHolder(frames, _maxWidthFrame, _maxHeightFrame));
57+
return compute(_exportGif, DataHolder(frames, _maxWidthFrame, _maxHeightFrame,percentProcess ));
5858
}
5959

6060
static Future<List<int>?> _exportGif(DataHolder data) async {
@@ -63,8 +63,12 @@ class Exporter {
6363
int height = data.height;
6464

6565
image.Image mainImage = image.Image.empty();
66-
66+
int i =1;
67+
int max = frames.length;
6768
for (final frame in frames) {
69+
double percent = double.parse((i / max).toStringAsFixed(4));
70+
data.percentProcess?.call(percent);
71+
i+=1;
6872
final iAsBytes = frame.image.buffer.asUint8List();
6973
final decodedImage = image.decodePng(iAsBytes);
7074

@@ -116,6 +120,7 @@ class Exporter {
116120
// a transparency threshold.
117121
final numFrames = srcImage.frames.length;
118122
for (var frameIndex = 0; frameIndex < numFrames; frameIndex++) {
123+
119124
final srcFrame = srcImage.frames[frameIndex];
120125
final newFrame = newImage.frames[frameIndex];
121126

@@ -143,7 +148,8 @@ class RawFrame {
143148
}
144149

145150
class DataHolder {
146-
DataHolder(this.frames, this.width, this.height);
151+
DataHolder(this.frames, this.width, this.height, this.percentProcess);
152+
ValueChanged<double>? percentProcess;
147153

148154
List<RawFrame> frames;
149155

0 commit comments

Comments
 (0)