-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae20a51
commit b4d9680
Showing
9 changed files
with
358 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'layer_menu_state_data.freezed.dart'; | ||
|
||
@immutable | ||
@freezed | ||
class LayerMenuStateData with _$LayerMenuStateData { | ||
const factory LayerMenuStateData({ | ||
required bool isVisible, | ||
}) = _LayerMenuStateData; | ||
} |
135 changes: 135 additions & 0 deletions
135
lib/core/providers/state/layer_menu_state_data.freezed.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// coverage:ignore-file | ||
// GENERATED CODE - DO NOT MODIFY BY HAND | ||
// ignore_for_file: type=lint | ||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark | ||
|
||
part of 'layer_menu_state_data.dart'; | ||
|
||
// ************************************************************************** | ||
// FreezedGenerator | ||
// ************************************************************************** | ||
|
||
T _$identity<T>(T value) => value; | ||
|
||
final _privateConstructorUsedError = UnsupportedError( | ||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); | ||
|
||
/// @nodoc | ||
mixin _$LayerMenuStateData { | ||
bool get isVisible => throw _privateConstructorUsedError; | ||
|
||
@JsonKey(ignore: true) | ||
$LayerMenuStateDataCopyWith<LayerMenuStateData> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $LayerMenuStateDataCopyWith<$Res> { | ||
factory $LayerMenuStateDataCopyWith( | ||
LayerMenuStateData value, $Res Function(LayerMenuStateData) then) = | ||
_$LayerMenuStateDataCopyWithImpl<$Res, LayerMenuStateData>; | ||
@useResult | ||
$Res call({bool isVisible}); | ||
} | ||
|
||
/// @nodoc | ||
class _$LayerMenuStateDataCopyWithImpl<$Res, $Val extends LayerMenuStateData> | ||
implements $LayerMenuStateDataCopyWith<$Res> { | ||
_$LayerMenuStateDataCopyWithImpl(this._value, this._then); | ||
|
||
// ignore: unused_field | ||
final $Val _value; | ||
// ignore: unused_field | ||
final $Res Function($Val) _then; | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? isVisible = null, | ||
}) { | ||
return _then(_value.copyWith( | ||
isVisible: null == isVisible | ||
? _value.isVisible | ||
: isVisible // ignore: cast_nullable_to_non_nullable | ||
as bool, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
abstract class _$$LayerMenuStateDataImplCopyWith<$Res> | ||
implements $LayerMenuStateDataCopyWith<$Res> { | ||
factory _$$LayerMenuStateDataImplCopyWith(_$LayerMenuStateDataImpl value, | ||
$Res Function(_$LayerMenuStateDataImpl) then) = | ||
__$$LayerMenuStateDataImplCopyWithImpl<$Res>; | ||
@override | ||
@useResult | ||
$Res call({bool isVisible}); | ||
} | ||
|
||
/// @nodoc | ||
class __$$LayerMenuStateDataImplCopyWithImpl<$Res> | ||
extends _$LayerMenuStateDataCopyWithImpl<$Res, _$LayerMenuStateDataImpl> | ||
implements _$$LayerMenuStateDataImplCopyWith<$Res> { | ||
__$$LayerMenuStateDataImplCopyWithImpl(_$LayerMenuStateDataImpl _value, | ||
$Res Function(_$LayerMenuStateDataImpl) _then) | ||
: super(_value, _then); | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? isVisible = null, | ||
}) { | ||
return _then(_$LayerMenuStateDataImpl( | ||
isVisible: null == isVisible | ||
? _value.isVisible | ||
: isVisible // ignore: cast_nullable_to_non_nullable | ||
as bool, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
class _$LayerMenuStateDataImpl implements _LayerMenuStateData { | ||
const _$LayerMenuStateDataImpl({required this.isVisible}); | ||
|
||
@override | ||
final bool isVisible; | ||
|
||
@override | ||
String toString() { | ||
return 'LayerMenuStateData(isVisible: $isVisible)'; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$LayerMenuStateDataImpl && | ||
(identical(other.isVisible, isVisible) || | ||
other.isVisible == isVisible)); | ||
} | ||
|
||
@override | ||
int get hashCode => Object.hash(runtimeType, isVisible); | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$LayerMenuStateDataImplCopyWith<_$LayerMenuStateDataImpl> get copyWith => | ||
__$$LayerMenuStateDataImplCopyWithImpl<_$LayerMenuStateDataImpl>( | ||
this, _$identity); | ||
} | ||
|
||
abstract class _LayerMenuStateData implements LayerMenuStateData { | ||
const factory _LayerMenuStateData({required final bool isVisible}) = | ||
_$LayerMenuStateDataImpl; | ||
|
||
@override | ||
bool get isVisible; | ||
@override | ||
@JsonKey(ignore: true) | ||
_$$LayerMenuStateDataImplCopyWith<_$LayerMenuStateDataImpl> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:paintroid/core/providers/state/layer_menu_state_data.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'layer_menu_state_provider.g.dart'; | ||
|
||
@Riverpod(keepAlive: true) | ||
class LayerMenuStateProvider extends _$LayerMenuStateProvider { | ||
@override | ||
LayerMenuStateData build() { | ||
return const LayerMenuStateData( | ||
isVisible: false, | ||
); | ||
} | ||
|
||
void toggleVisibility() { | ||
state = state.copyWith(isVisible: !state.isVisible); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
lib/ui/pages/workspace_page/components/layer_menu/layer_menu.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:paintroid/core/providers/state/layer_menu_state_provider.dart'; | ||
import 'package:paintroid/ui/shared/fade_in_out_widget.dart'; | ||
|
||
class LayerMenu extends ConsumerWidget { | ||
const LayerMenu({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final isVisible = ref.watch( | ||
layerMenuStateProvider.select((state) => state.isVisible), | ||
); | ||
return Positioned( | ||
top: 32, | ||
bottom: 32, | ||
right: 8, | ||
child: FadeInOutWidget( | ||
isVisible: isVisible, | ||
child: Container( | ||
width: 200, | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
borderRadius: BorderRadius.circular(12), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.