Skip to content

Commit e66342d

Browse files
authored
feat: update flutter_ume_kit_ui (#107)
* feat: update flutter_ume_kit_ui * feat: update flutter_ume_kit_ui version * feat: 更新日志 * feat: 部分非必要修改回退 & 添加英文更新日志 * feat: fix issues
1 parent ee172ec commit e66342d

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

kits/flutter_ume_kit_ui/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 1.1.1
4+
5+
* image: ^3.0.5 升级到 image: ^4.0.15
6+
* quiver: ^3.0.1 升级到 quiver: ^3.2.1
7+
* mockito: ^5.0.12 升级到 mockito: ^5.3.2
8+
9+
* Bump image from 3.0.5 to 4.0.15
10+
* Bump quiver from 3.0.1 to 3.2.1
11+
* Bump mockito from 5.0.12 to 5.3.2
12+
13+
314
## 1.1.0
415

516
* 适配 Flutter 3.7,不兼容旧版本的适配

kits/flutter_ume_kit_ui/lib/components/color_sucker/color_sucker.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,11 @@ class _ColorSuckerState extends State<ColorSucker> {
129129
if (_snapshot == null) return;
130130
double px = globalPosition.dx;
131131
double py = globalPosition.dy;
132-
int pixel32 = _snapshot!.getPixelSafe(px.toInt(), py.toInt());
133-
int hex = _abgrToArgb(pixel32);
134-
_currentColor = Color(hex);
135-
}
136132

137-
int _abgrToArgb(int argbColor) {
138-
int r = (argbColor >> 16) & 0xFF;
139-
int b = argbColor & 0xFF;
140-
return (argbColor & 0xFF00FF00) | (b << 16) | r;
133+
img.Pixel pixel = _snapshot!.getPixelSafe(px.toInt(), py.toInt());
134+
135+
_currentColor = Color.fromARGB(
136+
pixel.a.toInt(), pixel.r.toInt(), pixel.g.toInt(), pixel.b.toInt());
141137
}
142138

143139
@override

kits/flutter_ume_kit_ui/lib/third_party/cyclop/lib/src/utils.dart

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import 'dart:ui' as ui;
22

3-
import 'package:flutter/gestures.dart';
43
import 'package:flutter/material.dart';
54
import 'package:flutter/rendering.dart';
65
import 'package:image/image.dart' as img;
7-
86
//bool get isPhoneScreen => !(screenSize.shortestSide >= 600);
97

108
Size get screenSize => ui.window.physicalSize / ui.window.devicePixelRatio;
@@ -92,36 +90,32 @@ List<Color> getPixelColors(
9290
),
9391
);
9492

95-
Color getPixelColor(img.Image image, Offset offset) => (offset.dx >= 0 &&
96-
offset.dy >= 0 &&
97-
offset.dx < image.width &&
98-
offset.dy < image.height)
99-
? abgr2Color(image.getPixel(offset.dx.toInt(), offset.dy.toInt()))
100-
: const Color(0x00000000);
93+
ui.Color getPixelColor(img.Image image, Offset offset) {
94+
img.Pixel pixel = image.getPixelSafe(offset.dx.toInt(), offset.dy.toInt());
95+
96+
return (offset.dx >= 0 &&
97+
offset.dy >= 0 &&
98+
offset.dx < image.width &&
99+
offset.dy < image.height)
100+
? Color.fromARGB(
101+
pixel.a.toInt(), pixel.r.toInt(), pixel.g.toInt(), pixel.b.toInt())
102+
: const Color(0x00000000);
103+
}
101104

102105
ui.Offset _offsetFromIndex(int index, int numColumns) => Offset(
103106
(index % numColumns).toDouble(),
104107
((index ~/ numColumns) % numColumns).toDouble(),
105108
);
106109

107-
Color abgr2Color(int value) {
108-
final a = (value >> 24) & 0xFF;
109-
final b = (value >> 16) & 0xFF;
110-
final g = (value >> 8) & 0xFF;
111-
final r = (value >> 0) & 0xFF;
112-
113-
return Color.fromARGB(a, r, g, b);
114-
}
115-
116110
Future<img.Image?> repaintBoundaryToImage(
117111
RenderRepaintBoundary renderer,
118112
) async {
119113
try {
120114
final rawImage = await renderer.toImage(pixelRatio: 1);
121-
final byteData =
122-
await rawImage.toByteData(format: ui.ImageByteFormat.rawRgba);
115+
final byteData = await rawImage.toByteData(format: ui.ImageByteFormat.png);
123116
final pngBytes = byteData!.buffer.asUint8List();
124-
return img.Image.fromBytes(rawImage.width, rawImage.height, pngBytes);
117+
118+
return img.decodeImage(pngBytes);
125119
} catch (err) {
126120
return null;
127121
}

kits/flutter_ume_kit_ui/lib/third_party/cyclop/lib/src/widgets/eyedrop/eye_dropper_layer.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:ui';
22

3-
import 'package:flutter/gestures.dart';
43
import 'package:flutter/material.dart';
54
import 'package:flutter/rendering.dart';
65
import 'package:image/image.dart' as img;

kits/flutter_ume_kit_ui/lib/third_party/cyclop/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ environment:
99
dependencies:
1010
flutter:
1111
sdk: flutter
12-
image: ^3.0.5
13-
quiver: ^3.0.1
14-
basics: ^0.6.0
12+
image: ^4.0.15
13+
quiver: ^3.2.1
14+
basics: ^0.10.0
1515

1616
dev_dependencies:
1717
flutter_test:
1818
sdk: flutter
19-
flutter_lints: ^1.0.4
19+
flutter_lints: ^2.0.1
2020

2121
flutter:

kits/flutter_ume_kit_ui/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_ume_kit_ui
22
description: UI Kits for flutter_ume.
3-
version: 1.1.0
3+
version: 1.1.1
44
homepage: https://github.com/bytedance/flutter_ume
55

66
environment:
@@ -14,14 +14,14 @@ dependencies:
1414
touch_indicator: ^2.0.0
1515

1616
# for Cyclop
17-
image: ^3.0.5
18-
quiver: ^3.0.1
17+
image: ^4.0.15
18+
quiver: ^3.2.1
1919
basics: ">=0.6.0 <0.11.0"
2020

2121
dev_dependencies:
2222
flutter_test:
2323
sdk: flutter
24-
mockito: ^5.0.12
24+
mockito: ^5.3.2
2525
flutter_coverage_badge:
2626
git:
2727
url: https://github.com/smileShirely/flutter_coverage_badge.git

0 commit comments

Comments
 (0)