From b03f83023c4dfeb81b80dbb69afa457e55998c62 Mon Sep 17 00:00:00 2001 From: CodeDoctorDE Date: Thu, 24 Oct 2024 13:59:54 +0200 Subject: [PATCH] Remove asking for name on layer creation --- api/lib/src/protocol/event.dart | 7 ++++--- api/lib/src/protocol/event.freezed.dart | 25 ++++++++++++++++++------- api/lib/src/protocol/event.g.dart | 4 +++- app/android/Gemfile.lock | 22 +++++++++++----------- app/lib/bloc/document_bloc.dart | 2 +- app/lib/views/navigator/layers.dart | 8 ++++---- metadata/en-US/changelogs/120.txt | 1 + 7 files changed, 42 insertions(+), 27 deletions(-) diff --git a/api/lib/src/protocol/event.dart b/api/lib/src/protocol/event.dart index 21244e8b9350..ea464d6b977f 100644 --- a/api/lib/src/protocol/event.dart +++ b/api/lib/src/protocol/event.dart @@ -127,9 +127,10 @@ class DocumentEvent extends ReplayEvent with _$DocumentEvent { String name, ) = CurrentLayerChanged; - const factory DocumentEvent.layerCreated( - String name, - ) = LayerCreated; + const factory DocumentEvent.layerCreated({ + @Default('') String name, + String? id, + }) = LayerCreated; const factory DocumentEvent.layerChanged( String id, { diff --git a/api/lib/src/protocol/event.freezed.dart b/api/lib/src/protocol/event.freezed.dart index 1558151cb2ea..d687b3b05b67 100644 --- a/api/lib/src/protocol/event.freezed.dart +++ b/api/lib/src/protocol/event.freezed.dart @@ -3095,7 +3095,7 @@ abstract class _$$LayerCreatedImplCopyWith<$Res> { _$LayerCreatedImpl value, $Res Function(_$LayerCreatedImpl) then) = __$$LayerCreatedImplCopyWithImpl<$Res>; @useResult - $Res call({String name}); + $Res call({String name, String? id}); } /// @nodoc @@ -3112,12 +3112,17 @@ class __$$LayerCreatedImplCopyWithImpl<$Res> @override $Res call({ Object? name = null, + Object? id = freezed, }) { return _then(_$LayerCreatedImpl( - null == name + name: null == name ? _value.name : name // ignore: cast_nullable_to_non_nullable as String, + id: freezed == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -3125,7 +3130,7 @@ class __$$LayerCreatedImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$LayerCreatedImpl extends LayerCreated { - const _$LayerCreatedImpl(this.name, {final String? $type}) + const _$LayerCreatedImpl({this.name = '', this.id, final String? $type}) : $type = $type ?? 'layerCreated', super._(); @@ -3133,14 +3138,17 @@ class _$LayerCreatedImpl extends LayerCreated { _$$LayerCreatedImplFromJson(json); @override + @JsonKey() final String name; + @override + final String? id; @JsonKey(name: 'type') final String $type; @override String toString() { - return 'DocumentEvent.layerCreated(name: $name)'; + return 'DocumentEvent.layerCreated(name: $name, id: $id)'; } @override @@ -3148,12 +3156,13 @@ class _$LayerCreatedImpl extends LayerCreated { return identical(this, other) || (other.runtimeType == runtimeType && other is _$LayerCreatedImpl && - (identical(other.name, name) || other.name == name)); + (identical(other.name, name) || other.name == name) && + (identical(other.id, id) || other.id == id)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, name); + int get hashCode => Object.hash(runtimeType, name, id); /// Create a copy of DocumentEvent /// with the given fields replaced by the non-null parameter values. @@ -3172,13 +3181,15 @@ class _$LayerCreatedImpl extends LayerCreated { } abstract class LayerCreated extends DocumentEvent { - const factory LayerCreated(final String name) = _$LayerCreatedImpl; + const factory LayerCreated({final String name, final String? id}) = + _$LayerCreatedImpl; const LayerCreated._() : super._(); factory LayerCreated.fromJson(Map json) = _$LayerCreatedImpl.fromJson; String get name; + String? get id; /// Create a copy of DocumentEvent /// with the given fields replaced by the non-null parameter values. diff --git a/api/lib/src/protocol/event.g.dart b/api/lib/src/protocol/event.g.dart index 29106242fc6b..b3c524dcc00a 100644 --- a/api/lib/src/protocol/event.g.dart +++ b/api/lib/src/protocol/event.g.dart @@ -386,13 +386,15 @@ Map _$$CurrentLayerChangedImplToJson( }; _$LayerCreatedImpl _$$LayerCreatedImplFromJson(Map json) => _$LayerCreatedImpl( - json['name'] as String, + name: json['name'] as String? ?? '', + id: json['id'] as String?, $type: json['type'] as String?, ); Map _$$LayerCreatedImplToJson(_$LayerCreatedImpl instance) => { 'name': instance.name, + 'id': instance.id, 'type': instance.$type, }; diff --git a/app/android/Gemfile.lock b/app/android/Gemfile.lock index 1088ae494b49..33a65e12c79a 100644 --- a/app/android/Gemfile.lock +++ b/app/android/Gemfile.lock @@ -10,20 +10,20 @@ GEM artifactory (3.0.17) atomos (0.1.3) aws-eventstream (1.3.0) - aws-partitions (1.991.0) - aws-sdk-core (3.209.1) + aws-partitions (1.994.0) + aws-sdk-core (3.211.0) aws-eventstream (~> 1, >= 1.3.0) - aws-partitions (~> 1, >= 1.651.0) + aws-partitions (~> 1, >= 1.992.0) aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.94.0) - aws-sdk-core (~> 3, >= 3.207.0) + aws-sdk-kms (1.95.0) + aws-sdk-core (~> 3, >= 3.210.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.168.0) - aws-sdk-core (~> 3, >= 3.207.0) + aws-sdk-s3 (1.169.0) + aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) - aws-sigv4 (1.10.0) + aws-sigv4 (1.10.1) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) base64 (0.2.0) @@ -140,7 +140,7 @@ GEM google-cloud-core (~> 1.6) googleauth (~> 1.9) mini_mime (~> 1.0) - googleauth (1.11.1) + googleauth (1.11.2) faraday (>= 1.0, < 3.a) google-cloud-env (~> 2.1) jwt (>= 1.4, < 3.0) @@ -152,7 +152,7 @@ GEM domain_name (~> 0.5) httpclient (2.8.3) jmespath (1.6.2) - json (2.7.2) + json (2.7.3) jwt (2.9.3) base64 mini_magick (4.13.2) @@ -173,7 +173,7 @@ GEM trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.3.8) + rexml (3.3.9) rouge (2.0.7) ruby2_keywords (0.0.5) rubyzip (2.3.2) diff --git a/app/lib/bloc/document_bloc.dart b/app/lib/bloc/document_bloc.dart index 6870391b9dea..2f30e538bf7c 100644 --- a/app/lib/bloc/document_bloc.dart +++ b/app/lib/bloc/document_bloc.dart @@ -621,7 +621,7 @@ class DocumentBloc extends ReplayBloc { state: current.copyWith( page: current.page.copyWith(layers: [ ...current.page.layers, - DocumentLayer(id: createUniqueId(), name: event.name), + DocumentLayer(id: event.id ?? createUniqueId(), name: event.name), ]), ), ); diff --git a/app/lib/views/navigator/layers.dart b/app/lib/views/navigator/layers.dart index 34c12b7b6a43..c85edebd8f38 100644 --- a/app/lib/views/navigator/layers.dart +++ b/app/lib/views/navigator/layers.dart @@ -153,10 +153,10 @@ class LayersView extends StatelessWidget { final bloc = context.read(); final state = bloc.state; if (state is! DocumentLoadSuccess) return; - final result = await showDialog( - builder: (context) => NameDialog(), context: context); - if (result == null) return; - bloc.add(LayerCreated(result)); + final id = createUniqueId(); + bloc + ..add(LayerCreated(id: id)) + ..add(CurrentLayerChanged(id)); }), ), ) diff --git a/metadata/en-US/changelogs/120.txt b/metadata/en-US/changelogs/120.txt index ee78cee4277c..6c46daba6e75 100644 --- a/metadata/en-US/changelogs/120.txt +++ b/metadata/en-US/changelogs/120.txt @@ -1,4 +1,5 @@ * Add layer merging +* Remove asking for name on layer creation * Fix layer rendering Read more here: https://linwood.dev/butterfly/2.3.0-beta.0 \ No newline at end of file