Skip to content

Commit

Permalink
Remove asking for name on layer creation
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Oct 24, 2024
1 parent 6250fbf commit b03f830
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 27 deletions.
7 changes: 4 additions & 3 deletions api/lib/src/protocol/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
25 changes: 18 additions & 7 deletions api/lib/src/protocol/event.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -3112,48 +3112,57 @@ 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?,
));
}
}

/// @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._();

factory _$LayerCreatedImpl.fromJson(Map<String, dynamic> json) =>
_$$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
bool operator ==(Object other) {
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.
Expand All @@ -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<String, dynamic> 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.
Expand Down
4 changes: 3 additions & 1 deletion api/lib/src/protocol/event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/bloc/document_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class DocumentBloc extends ReplayBloc<DocumentEvent, DocumentState> {
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),
]),
),
);
Expand Down
8 changes: 4 additions & 4 deletions app/lib/views/navigator/layers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ class LayersView extends StatelessWidget {
final bloc = context.read<DocumentBloc>();
final state = bloc.state;
if (state is! DocumentLoadSuccess) return;
final result = await showDialog<String>(
builder: (context) => NameDialog(), context: context);
if (result == null) return;
bloc.add(LayerCreated(result));
final id = createUniqueId();
bloc
..add(LayerCreated(id: id))
..add(CurrentLayerChanged(id));
}),
),
)
Expand Down
1 change: 1 addition & 0 deletions metadata/en-US/changelogs/120.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b03f830

Please sign in to comment.