Skip to content

Commit

Permalink
feat: update flutter_ume_kit_ui (#107)
Browse files Browse the repository at this point in the history
* feat: update flutter_ume_kit_ui

* feat: update flutter_ume_kit_ui version

* feat: 更新日志

* feat: 部分非必要修改回退 & 添加英文更新日志

* feat: fix issues
  • Loading branch information
p709723778 committed Mar 30, 2023
1 parent ee172ec commit e66342d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
11 changes: 11 additions & 0 deletions kits/flutter_ume_kit_ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 1.1.1

* image: ^3.0.5 升级到 image: ^4.0.15
* quiver: ^3.0.1 升级到 quiver: ^3.2.1
* mockito: ^5.0.12 升级到 mockito: ^5.3.2

* Bump image from 3.0.5 to 4.0.15
* Bump quiver from 3.0.1 to 3.2.1
* Bump mockito from 5.0.12 to 5.3.2


## 1.1.0

* 适配 Flutter 3.7,不兼容旧版本的适配
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,11 @@ class _ColorSuckerState extends State<ColorSucker> {
if (_snapshot == null) return;
double px = globalPosition.dx;
double py = globalPosition.dy;
int pixel32 = _snapshot!.getPixelSafe(px.toInt(), py.toInt());
int hex = _abgrToArgb(pixel32);
_currentColor = Color(hex);
}

int _abgrToArgb(int argbColor) {
int r = (argbColor >> 16) & 0xFF;
int b = argbColor & 0xFF;
return (argbColor & 0xFF00FF00) | (b << 16) | r;
img.Pixel pixel = _snapshot!.getPixelSafe(px.toInt(), py.toInt());

_currentColor = Color.fromARGB(
pixel.a.toInt(), pixel.r.toInt(), pixel.g.toInt(), pixel.b.toInt());
}

@override
Expand Down
34 changes: 14 additions & 20 deletions kits/flutter_ume_kit_ui/lib/third_party/cyclop/lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'dart:ui' as ui;

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:image/image.dart' as img;

//bool get isPhoneScreen => !(screenSize.shortestSide >= 600);

Size get screenSize => ui.window.physicalSize / ui.window.devicePixelRatio;
Expand Down Expand Up @@ -92,36 +90,32 @@ List<Color> getPixelColors(
),
);

Color getPixelColor(img.Image image, Offset offset) => (offset.dx >= 0 &&
offset.dy >= 0 &&
offset.dx < image.width &&
offset.dy < image.height)
? abgr2Color(image.getPixel(offset.dx.toInt(), offset.dy.toInt()))
: const Color(0x00000000);
ui.Color getPixelColor(img.Image image, Offset offset) {
img.Pixel pixel = image.getPixelSafe(offset.dx.toInt(), offset.dy.toInt());

return (offset.dx >= 0 &&
offset.dy >= 0 &&
offset.dx < image.width &&
offset.dy < image.height)
? Color.fromARGB(
pixel.a.toInt(), pixel.r.toInt(), pixel.g.toInt(), pixel.b.toInt())
: const Color(0x00000000);
}

ui.Offset _offsetFromIndex(int index, int numColumns) => Offset(
(index % numColumns).toDouble(),
((index ~/ numColumns) % numColumns).toDouble(),
);

Color abgr2Color(int value) {
final a = (value >> 24) & 0xFF;
final b = (value >> 16) & 0xFF;
final g = (value >> 8) & 0xFF;
final r = (value >> 0) & 0xFF;

return Color.fromARGB(a, r, g, b);
}

Future<img.Image?> repaintBoundaryToImage(
RenderRepaintBoundary renderer,
) async {
try {
final rawImage = await renderer.toImage(pixelRatio: 1);
final byteData =
await rawImage.toByteData(format: ui.ImageByteFormat.rawRgba);
final byteData = await rawImage.toByteData(format: ui.ImageByteFormat.png);
final pngBytes = byteData!.buffer.asUint8List();
return img.Image.fromBytes(rawImage.width, rawImage.height, pngBytes);

return img.decodeImage(pngBytes);
} catch (err) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:ui';

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:image/image.dart' as img;
Expand Down
8 changes: 4 additions & 4 deletions kits/flutter_ume_kit_ui/lib/third_party/cyclop/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ environment:
dependencies:
flutter:
sdk: flutter
image: ^3.0.5
quiver: ^3.0.1
basics: ^0.6.0
image: ^4.0.15
quiver: ^3.2.1
basics: ^0.10.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.4
flutter_lints: ^2.0.1

flutter:
8 changes: 4 additions & 4 deletions kits/flutter_ume_kit_ui/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_ume_kit_ui
description: UI Kits for flutter_ume.
version: 1.1.0
version: 1.1.1
homepage: https://github.com/bytedance/flutter_ume

environment:
Expand All @@ -14,14 +14,14 @@ dependencies:
touch_indicator: ^2.0.0

# for Cyclop
image: ^3.0.5
quiver: ^3.0.1
image: ^4.0.15
quiver: ^3.2.1
basics: ">=0.6.0 <0.11.0"

dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.0.12
mockito: ^5.3.2
flutter_coverage_badge:
git:
url: https://github.com/smileShirely/flutter_coverage_badge.git
Expand Down

0 comments on commit e66342d

Please sign in to comment.