|
@@ -1,5 +1,3 @@
|
|
|
-import 'dart:ffi';
|
|
|
-
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:kmpdfkit_demo/widgets/constains.dart';
|
|
@@ -106,9 +104,9 @@ CancelListener setReaderViewCallbackListener(
|
|
|
/// ```dart
|
|
|
/// setReaderViewContextMenuHelperListener((annotBean) {
|
|
|
/// //show annotation attribute options widget
|
|
|
-/// _showAttributeOptionsModalBottomSheet(context, annotBean, (color, alpha) {
|
|
|
+/// _showAttributeOptionsModalBottomSheet(context, annotBean,(AnnotAttributeBean bean) {
|
|
|
/// modifyAnnotationAttribute(
|
|
|
-/// annotationType: annotBean.annotType, color: color, alpha: alpha);
|
|
|
+/// annotationType: annotBean.annotType, bean: bean);
|
|
|
/// }, (){
|
|
|
/// dismissModifyAnnotationAttribute();
|
|
|
/// });
|
|
@@ -123,31 +121,9 @@ void setReaderViewContextMenuHelperListener(
|
|
|
Map<dynamic, dynamic> result = event;
|
|
|
String annotType = result[EventParameters.annotType];
|
|
|
AnnotationType type = AnnotationType.values.byName(annotType);
|
|
|
- String? annotAttrColor = result[EventParameters.annotAttrColor];
|
|
|
- int annotAttrAlpha = result[EventParameters.annotAttrAlpha]??255;
|
|
|
- double borderWidth = result[EventParameters.annotAttrBorderWidth] ?? 2;
|
|
|
- String? borderColor = result[EventParameters.annotAttrBorderColor];
|
|
|
- int borderColorAlpha =
|
|
|
- result[EventParameters.annotAttrBorderColorAlpha] ?? 255;
|
|
|
- String? fillColor = result[EventParameters.annotAttrFillColor];
|
|
|
- int fillColorAlpha = result[EventParameters.annotAttrFillColorAlpha] ?? 255;
|
|
|
- String shapeTypeStr = result[EventParameters.annotAttrShapeType] ?? "";
|
|
|
- AnnotationType shapeType = shapeTypeStr.isEmpty
|
|
|
- ? AnnotationType.square
|
|
|
- : AnnotationType.values.byName(shapeTypeStr);
|
|
|
-
|
|
|
showAnnotationAttributeOptions(AnnotBean(
|
|
|
annotType: type,
|
|
|
- attributeBean: AnnotAttributeBean(
|
|
|
- color: annotAttrColor != null ? HexColor.fromHex(annotAttrColor) : Colors.red,
|
|
|
- alpha: annotAttrAlpha,
|
|
|
- borderWidth: borderWidth,
|
|
|
- borderColor: borderColor != null ? HexColor.fromHex(borderColor) : Colors.red,
|
|
|
- borderColorAlpha: borderColorAlpha,
|
|
|
- fillColor: fillColor != null ? HexColor.fromHex(fillColor) : Colors.red,
|
|
|
- fillColorAlpha: fillColorAlpha,
|
|
|
- shapeType: shapeType,
|
|
|
- showShapeTypeWidget: false),
|
|
|
+ attributeBean: AnnotAttributeBean.parseMapValue(type, result),
|
|
|
));
|
|
|
}, cancelOnError: true);
|
|
|
}
|
|
@@ -158,10 +134,10 @@ void setReaderViewContextMenuHelperListener(
|
|
|
/// ```dart
|
|
|
/// setReaderViewContextMenuHelperListener((annotBean) {
|
|
|
/// //show annotation attribute options widget
|
|
|
-/// _showAttributeOptionsModalBottomSheet(context, annotBean, (color, alpha) {
|
|
|
+/// _showAttributeOptionsModalBottomSheet(context, annotBean,(AnnotAttributeBean bean) {
|
|
|
/// //modify annotation attribute
|
|
|
/// modifyAnnotationAttribute(
|
|
|
-/// annotationType: annotBean.annotType, color: color, alpha: alpha);
|
|
|
+/// annotationType: annotBean.annotType, bean: bean);
|
|
|
/// }, (){
|
|
|
/// dismissModifyAnnotationAttribute();
|
|
|
/// });
|
|
@@ -171,16 +147,8 @@ void setReaderViewContextMenuHelperListener(
|
|
|
void modifyAnnotationAttribute(
|
|
|
{required AnnotationType annotationType,
|
|
|
required AnnotAttributeBean bean}) async {
|
|
|
- await _modifyAnnotAttrChannel.invokeMethod(Functions.modifyAnnotAttribute, {
|
|
|
- EventParameters.annotAttrColor: bean.color.toHex(),
|
|
|
- EventParameters.annotAttrAlpha: bean.alpha,
|
|
|
- EventParameters.annotType: annotationType.name,
|
|
|
- EventParameters.annotAttrBorderWidth: bean.borderWidth,
|
|
|
- EventParameters.annotAttrBorderColor: bean.borderColor.toHex(),
|
|
|
- EventParameters.annotAttrBorderColorAlpha: bean.borderColorAlpha,
|
|
|
- EventParameters.annotAttrFillColor: bean.fillColor.toHex(),
|
|
|
- EventParameters.annotAttrFillColorAlpha: bean.fillColorAlpha
|
|
|
- });
|
|
|
+ await _modifyAnnotAttrChannel.invokeMethod(
|
|
|
+ Functions.modifyAnnotAttribute, bean.toMapValues(annotationType));
|
|
|
}
|
|
|
|
|
|
/// Please call this method after the annotation attribute adjustment interface is closed.
|
|
@@ -318,40 +286,16 @@ Future<int> setReadBackgroundColor(int backgroundColor) async {
|
|
|
{EventParameters.readBackgroundColor: backgroundColor});
|
|
|
}
|
|
|
|
|
|
-///Get annotation attributes based on annotation type
|
|
|
-///```dart
|
|
|
+/// Get annotation attributes based on annotation type
|
|
|
+///
|
|
|
+/// ```dart
|
|
|
/// AnnotAttributeBean highlight = await getAnnotAttribute(AnnotType.highlight);
|
|
|
-///```
|
|
|
+/// ```
|
|
|
/// return annotation attributes color and alpha
|
|
|
Future<AnnotAttributeBean> getAnnotAttribute(AnnotationType annotType) async {
|
|
|
Map<dynamic, dynamic> annotAttrMap = await _methodChannel.invokeMethod(
|
|
|
Functions.getAnnotAttribute, {EventParameters.annotType: annotType.name});
|
|
|
- String color =
|
|
|
- annotAttrMap[EventParameters.annotAttrColor] ?? Colors.red.toHex();
|
|
|
- int alpha = annotAttrMap[EventParameters.annotAttrAlpha] ?? 255;
|
|
|
- num borderWidth = annotAttrMap[EventParameters.annotAttrBorderWidth] ?? 2;
|
|
|
- String borderColor = annotAttrMap[EventParameters.annotAttrBorderColor] ??
|
|
|
- Colors.red.toHex();
|
|
|
- int borderColorAlpha =
|
|
|
- annotAttrMap[EventParameters.annotAttrBorderColorAlpha] ?? 255;
|
|
|
- String fillColor = annotAttrMap[EventParameters.annotAttrFillColor] ??
|
|
|
- Colors.red.toHex();
|
|
|
- int fillColorAlpha =
|
|
|
- annotAttrMap[EventParameters.annotAttrFillColorAlpha] ?? 255;
|
|
|
-
|
|
|
- String shapeType = annotAttrMap[EventParameters.annotAttrShapeType] ?? "";
|
|
|
- AnnotationType type =
|
|
|
- shapeType.isEmpty ? annotType : AnnotationType.values.byName(shapeType);
|
|
|
-
|
|
|
- return AnnotAttributeBean(
|
|
|
- color: HexColor.fromHex(color),
|
|
|
- alpha: alpha,
|
|
|
- borderWidth: borderWidth.toDouble(),
|
|
|
- borderColor: HexColor.fromHex(borderColor),
|
|
|
- borderColorAlpha: borderColorAlpha,
|
|
|
- fillColor: HexColor.fromHex(fillColor),
|
|
|
- fillColorAlpha: fillColorAlpha,
|
|
|
- shapeType: type);
|
|
|
+ return AnnotAttributeBean.parseMapValue(annotType, annotAttrMap);
|
|
|
}
|
|
|
|
|
|
///set annotation attributes
|
|
@@ -365,16 +309,7 @@ void setAnnotAttribute(
|
|
|
required AnnotAttributeBean bean}) async {
|
|
|
await _methodChannel.invokeMethod(Functions.setAnnotAttribute, {
|
|
|
EventParameters.annotType: annotationType.name,
|
|
|
- EventParameters.annotAttribute: {
|
|
|
- EventParameters.annotAttrColor: bean.color.toHex(),
|
|
|
- EventParameters.annotAttrAlpha: bean.alpha,
|
|
|
- EventParameters.annotAttrBorderWidth: bean.borderWidth,
|
|
|
- EventParameters.annotAttrBorderColor: bean.borderColor.toHex(),
|
|
|
- EventParameters.annotAttrBorderColorAlpha: bean.borderColorAlpha,
|
|
|
- EventParameters.annotAttrFillColor: bean.fillColor.toHex(),
|
|
|
- EventParameters.annotAttrFillColorAlpha: bean.fillColorAlpha,
|
|
|
- EventParameters.annotAttrShapeType: bean.shapeType.name
|
|
|
- }
|
|
|
+ EventParameters.annotAttribute: bean.toMapValues(annotationType)
|
|
|
});
|
|
|
}
|
|
|
|