Skip to content

Commit

Permalink
Fix id
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 22, 2025
1 parent 15db4e7 commit fb7ced0
Show file tree
Hide file tree
Showing 17 changed files with 625 additions and 1,073 deletions.
22 changes: 22 additions & 0 deletions api/lib/helpers/mapper.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:typed_data';

import 'package:dart_leap/dart_leap.dart';
import 'package:dart_mappable/dart_mappable.dart';

Expand All @@ -17,3 +19,23 @@ class SecondsDateTimeMapper extends SimpleMapper<DateTime> {
return self?.secondsSinceEpoch;
}
}

class Uint8ListConverter extends SimpleMapper<Uint8List> {
const Uint8ListConverter();

@override
Uint8List decode(Object value) {
if (value is Uint8List) {
return value;
}
if (value is List) {
return Uint8List.fromList(value.cast<int>());
}
return Uint8List(0);
}

@override
Object? encode(Uint8List self) {
return self;
}
}
3 changes: 2 additions & 1 deletion api/lib/helpers/setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import 'package:dart_mappable/dart_mappable.dart';
import 'package:flow_api/helpers/mapper.dart';

void setupAPI() {
MapperContainer.globals.use(SecondsDateTimeMapper());
MapperContainer.globals
.useAll([SecondsDateTimeMapper(), Uint8ListConverter()]);
}
5 changes: 3 additions & 2 deletions api/lib/models/label/model.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:dart_leap/dart_leap.dart';
import 'package:dart_mappable/dart_mappable.dart';
import 'dart:typed_data';
import 'package:flow_api/models/model.dart';
Expand All @@ -10,13 +11,13 @@ class Label with LabelMappable, IdentifiedModel, NamedModel, DescriptiveModel {
final Uint8List? id;
@override
final String name, description;
final int color;
final SRGBColor color;

const Label({
this.id,
this.name = '',
this.description = '',
this.color = kColorBlack,
this.color = SRGBColor.black,
});

factory Label.fromDatabase(Map<String, dynamic> row) => LabelMapper.fromMap({
Expand Down
10 changes: 5 additions & 5 deletions api/lib/models/label/model.mapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class LabelMapper extends ClassMapperBase<Label> {
static String _$description(Label v) => v.description;
static const Field<Label, String> _f$description =
Field('description', _$description, opt: true, def: '');
static int _$color(Label v) => v.color;
static const Field<Label, int> _f$color =
Field('color', _$color, opt: true, def: kColorBlack);
static SRGBColor _$color(Label v) => v.color;
static const Field<Label, SRGBColor> _f$color =
Field('color', _$color, opt: true, def: SRGBColor.black);

@override
final MappableFields<Label> fields = const {
Expand Down Expand Up @@ -94,7 +94,7 @@ extension LabelValueCopy<$R, $Out> on ObjectCopyWith<$R, Label, $Out> {

abstract class LabelCopyWith<$R, $In extends Label, $Out>
implements ClassCopyWith<$R, $In, $Out> {
$R call({Uint8List? id, String? name, String? description, int? color});
$R call({Uint8List? id, String? name, String? description, SRGBColor? color});
LabelCopyWith<$R2, $In, $Out2> $chain<$R2, $Out2>(Then<$Out2, $R2> t);
}

Expand All @@ -109,7 +109,7 @@ class _LabelCopyWithImpl<$R, $Out> extends ClassCopyWithBase<$R, Label, $Out>
{Object? id = $none,
String? name,
String? description,
int? color}) =>
SRGBColor? color}) =>
$apply(FieldCopyWithData({
if (id != $none) #id: id,
if (name != null) #name: name,
Expand Down
18 changes: 9 additions & 9 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ packages:
dependency: "direct main"
description:
path: "packages/dart_leap"
ref: dfda6c2e3cef2e29511f97e9470fd4deb8e0c573
resolved-ref: dfda6c2e3cef2e29511f97e9470fd4deb8e0c573
url: "https://github.com/LinwoodDev/dart_pkgs"
ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
resolved-ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
dart_mappable:
Expand Down Expand Up @@ -259,10 +259,10 @@ packages:
dependency: transitive
description:
name: http_parser
sha256: "76d306a1c3afb33fe82e2bbacad62a61f409b5634c915fceb0d799de1a913360"
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
source: hosted
version: "4.1.1"
version: "4.1.2"
io:
dependency: transitive
description:
Expand Down Expand Up @@ -379,10 +379,10 @@ packages:
dependency: transitive
description:
name: pubspec_parse
sha256: "81876843eb50dc2e1e5b151792c9a985c5ed2536914115ed04e9c8528f6647b0"
sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082"
url: "https://pub.dev"
source: hosted
version: "1.4.0"
version: "1.5.0"
shelf:
dependency: transitive
description:
Expand Down Expand Up @@ -467,10 +467,10 @@ packages:
dependency: transitive
description:
name: stream_channel
sha256: "4ac0537115a24d772c408a2520ecd0abb99bca2ea9c4e634ccbdbfae64fe17ec"
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
version: "2.1.3"
version: "2.1.4"
stream_transform:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A starting point for Dart libraries or applications.
# homepage: https://www.example.com

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.3.0 <4.0.0"

dependencies:
meta: ^1.11.0
Expand All @@ -16,8 +16,8 @@ dependencies:
dart_mappable: ^4.3.0
dart_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: dfda6c2e3cef2e29511f97e9470fd4deb8e0c573
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
path: packages/dart_leap
dev_dependencies:
build_runner: ^2.4.14
Expand Down
22 changes: 11 additions & 11 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.1027.0)
aws-sdk-core (3.214.0)
aws-partitions (1.1041.0)
aws-sdk-core (3.216.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (1.97.0)
aws-sdk-core (~> 3, >= 3.216.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.176.1)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-s3 (1.178.0)
aws-sdk-core (~> 3, >= 3.216.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.1)
aws-sigv4 (1.11.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
Expand Down Expand Up @@ -67,7 +67,7 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastimage (2.4.0)
fastlane (2.226.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
Expand Down Expand Up @@ -155,7 +155,7 @@ GEM
httpclient (2.8.3)
jmespath (1.6.2)
json (2.9.1)
jwt (2.9.3)
jwt (2.10.1)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand All @@ -166,7 +166,7 @@ GEM
nkf (0.2.0)
optparse (0.6.0)
os (1.1.4)
plist (3.7.1)
plist (3.7.2)
public_suffix (6.0.1)
rake (13.2.1)
representable (3.2.0)
Expand All @@ -177,7 +177,7 @@ GEM
rexml (3.4.0)
rouge (3.28.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rubyzip (2.4.1)
screengrab (1.0.0)
fastlane (>= 2.0.0, < 3.0.0)
security (0.1.5)
Expand Down
4 changes: 1 addition & 3 deletions app/lib/api/storage/sources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class SourcesService {
final BehaviorSubject<SyncStatus> syncStatus =
BehaviorSubject.seeded(SyncStatus.synced);
final FlutterSecureStorage secureStorage = const FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
aOptions: AndroidOptions(),
);

SourcesService(this.settingsCubit);
Expand Down
10 changes: 5 additions & 5 deletions app/lib/pages/notes/label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ class LabelDialog extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
StatefulBuilder(
builder: (context, setState) => ColorButton(
builder: (context, setState) => ColorButton.srgb(
onTap: () async {
final result = await showDialog<ColorPickerResponse>(
context: context,
builder: (context) => ColorPicker(
value: Color(currentLabel.color),
value: currentLabel.color,
));
if (result == null) return;
setState(() =>
currentLabel = currentLabel.copyWith(color: result.color));
setState(() => currentLabel =
currentLabel.copyWith(color: result.toSRGB()));
},
color: Color(currentLabel.color).withAlpha(255),
color: currentLabel.color.withOpacity(1),
size: 25,
),
),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/pages/notes/navigator/labels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ class _NoteLabelsViewState extends State<_NoteLabelsView> {
return MenuAnchor(
builder: (context, controller, child) => Tooltip(
message: item.model.name,
child: ColorButton(
child: ColorButton.srgb(
onTap: () =>
widget.onChanged?.call(widget.filter.copyWith(
selectedLabel: selected ? null : item.model.id,
source: item.source,
)),
selected: selected,
color: Color(item.model.color).withAlpha(255),
color: item.model.color.withOpacity(1),
onLongPress: controller.toggle,
onSecondaryTap: controller.toggle,
),
Expand Down
4 changes: 2 additions & 2 deletions app/lib/pages/notes/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ class _NoteViewState extends State<NoteView> {
.map((e) => Padding(
padding: const EdgeInsets.all(8.0),
child: InputChip(
avatar: ColorButton(
color: Color(e.color),
avatar: ColorButton.srgb(
color: e.color,
),
label: Text(e.name),
onDeleted: () async {
Expand Down
4 changes: 2 additions & 2 deletions app/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

import connectivity_plus
import dynamic_color
import flutter_secure_storage_macos
import flutter_secure_storage_darwin
import package_info_plus
import path_provider_foundation
import screen_retriever_macos
Expand All @@ -20,7 +20,7 @@ import window_manager
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
FlutterSecureStorageDarwinPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageDarwinPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
Expand Down
Loading

0 comments on commit fb7ced0

Please sign in to comment.