mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2026-01-31 04:25:02 -06:00
feat:Update search
This commit is contained in:
@@ -29,3 +29,4 @@ export 'permissions/user_permissions.dart';
|
||||
export 'permissions/inherited_permissions.dart';
|
||||
export 'group_model.dart';
|
||||
export 'user_model.dart';
|
||||
export 'permissions/user_permission_extension.dart';
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:paperless_api/paperless_api.dart';
|
||||
|
||||
extension UserPermissionExtension on UserModel {
|
||||
bool hasPermission(PermissionAction action, PermissionTarget target) {
|
||||
return map(
|
||||
v3: (user) {
|
||||
final permission = [action.value, target.value].join("_");
|
||||
return user.userPermissions.any((element) => element == permission) ||
|
||||
user.inheritedPermissions.any((element) => element.split(".").last == permission);
|
||||
},
|
||||
v2: (_) => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:paperless_api/config/hive/hive_type_ids.dart';
|
||||
import 'package:paperless_api/src/models/permissions/user_permissions.dart';
|
||||
|
||||
part 'user_model.freezed.dart';
|
||||
part 'user_model.g.dart';
|
||||
@@ -42,29 +41,17 @@ class UserModel with _$UserModel {
|
||||
String? get fullName => map(
|
||||
v2: (value) => value.displayName,
|
||||
v3: (value) {
|
||||
if (value.firstName == null && value.lastName == null) {
|
||||
bool hasFirstName = value.firstName?.trim().isNotEmpty ?? false;
|
||||
bool hasLastName = value.lastName?.trim().isNotEmpty ?? false;
|
||||
if (hasFirstName && hasLastName) {
|
||||
return "${value.firstName!} ${value.lastName!}";
|
||||
} else if (hasFirstName) {
|
||||
return value.firstName!;
|
||||
} else if (hasLastName) {
|
||||
return value.lastName;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (value.firstName == null) {
|
||||
return value.lastName;
|
||||
}
|
||||
return "${value.firstName!} ${value.lastName ?? ''}";
|
||||
},
|
||||
);
|
||||
|
||||
bool hasPermission(PermissionAction action, PermissionTarget target) {
|
||||
return map(
|
||||
v3: (value) {
|
||||
if (value.isSuperuser) {
|
||||
return true;
|
||||
}
|
||||
final permissionIdentifier = "${action.value}_${target.value}";
|
||||
return value.userPermissions.contains(permissionIdentifier);
|
||||
},
|
||||
v2: (value) {
|
||||
// In previous versions, all users have all permissions.
|
||||
return true;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ subprojects {
|
||||
project.evaluationDependsOn(':app')
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
tasks.register("clean", Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:image/image.dart' as imglib;
|
||||
import 'package:camerawesome/camerawesome_plugin.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
late final List<CameraDescription> cameras;
|
||||
void main() async {
|
||||
@@ -19,27 +20,9 @@ class EdgeDetectionApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _EdgeDetectionAppState extends State<EdgeDetectionApp> {
|
||||
CameraImage? _image;
|
||||
late final CameraController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
() async {
|
||||
_controller = CameraController(
|
||||
cameras
|
||||
.where(
|
||||
(element) => element.lensDirection == CameraLensDirection.back)
|
||||
.first,
|
||||
ResolutionPreset.low,
|
||||
enableAudio: false,
|
||||
);
|
||||
await _controller.initialize();
|
||||
_controller.startImageStream((image) {
|
||||
setState(() => _image = image);
|
||||
});
|
||||
}();
|
||||
}
|
||||
|
||||
Uint8List concatenatePlanes(List<Plane> planes) {
|
||||
@@ -68,8 +51,7 @@ class _EdgeDetectionAppState extends State<EdgeDetectionApp> {
|
||||
// Fill image buffer with plane[0] from YUV420_888
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
final int uvIndex =
|
||||
uvPixelStride * (x / 2).floor() + uvRowStride * (y / 2).floor();
|
||||
final int uvIndex = uvPixelStride * (x / 2).floor() + uvRowStride * (y / 2).floor();
|
||||
final int index = y * width + x;
|
||||
|
||||
final yp = image.planes[0].bytes[index];
|
||||
@@ -77,9 +59,7 @@ class _EdgeDetectionAppState extends State<EdgeDetectionApp> {
|
||||
final vp = image.planes[2].bytes[uvIndex];
|
||||
// Calculate pixel color
|
||||
int r = (yp + vp * 1436 / 1024 - 179).round().clamp(0, 255);
|
||||
int g = (yp - up * 46549 / 131072 + 44 - vp * 93604 / 131072 + 91)
|
||||
.round()
|
||||
.clamp(0, 255);
|
||||
int g = (yp - up * 46549 / 131072 + 44 - vp * 93604 / 131072 + 91).round().clamp(0, 255);
|
||||
int b = (yp + up * 1814 / 1024 - 227).round().clamp(0, 255);
|
||||
// color: 0x FF FF FF FF
|
||||
// A B G R
|
||||
@@ -100,10 +80,22 @@ class _EdgeDetectionAppState extends State<EdgeDetectionApp> {
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
child: _image != null
|
||||
? convertYUV420toImageColor(_image!)
|
||||
: const Placeholder(),
|
||||
body: CameraAwesomeBuilder.awesome(
|
||||
saveConfig: SaveConfig.photo(
|
||||
pathBuilder: () =>
|
||||
getApplicationDocumentsDirectory().then((value) => "${value.path}/test.jpg"),
|
||||
),
|
||||
onImageForAnalysis: (image) async {},
|
||||
imageAnalysisConfig: AnalysisConfig(
|
||||
// Android specific options
|
||||
androidOptions: const AndroidAnalysisOptions.yuv420(
|
||||
// Target width (CameraX will chose the closest resolution to this width)
|
||||
width: 250,
|
||||
),
|
||||
// Wether to start automatically the analysis (true by default)
|
||||
autoStart: true,
|
||||
// Max frames per second, null for no limit (default)
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -65,6 +65,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1+3"
|
||||
camerawesome:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: camerawesome
|
||||
sha256: "0fd4ad7cf85ced7c3018edbe5a66d8c4b630ada7120b02c01961db3ea36f52ce"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
carousel_slider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: carousel_slider
|
||||
sha256: "9c695cc963bf1d04a47bd6021f68befce8970bcd61d24938e1fb0918cf5d9c42"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.1"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -89,6 +105,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.1"
|
||||
colorfilter_generator:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: colorfilter_generator
|
||||
sha256: ccc2995e440b1d828d55d99150e7cad64624f3cb4a1e235000de3f93cf10d35c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.8"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -216,6 +240,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
matrix2d:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matrix2d
|
||||
sha256: "188718dd3bc2a31e372cfd0791b0f77f4f13ea76164147342cc378d9132949e7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -335,6 +367,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rxdart
|
||||
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.27.7"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
||||
@@ -8,6 +8,7 @@ environment:
|
||||
flutter: ">=2.5.0"
|
||||
|
||||
dependencies:
|
||||
camerawesome: ^1.4.0
|
||||
ffi: ^2.0.1
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user