Skip to content

Commit 0ab53a1

Browse files
committed
InkWells #1
1 parent 2e862ca commit 0ab53a1

37 files changed

+219
-34
lines changed

lib/src/api/mixins.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:json_annotation/json_annotation.dart';
66

7+
import 'models/ink_well.dart';
78
import 'models/models.dart';
89
import 'nodes/nodes.dart';
910

@@ -40,6 +41,8 @@ abstract class DefaultShapeNode extends SceneNode
4041
bool isMask = false,
4142
List<Effect> effects = const [],
4243
BlendModeC blendMode = BlendModeC.srcOver,
44+
InkWellModel? inkWell,
45+
4346
// [GeometryMixin] properties.
4447
List<PaintModel> fills = const [],
4548
List<PaintModel> strokes = const [],
@@ -55,6 +58,7 @@ abstract class DefaultShapeNode extends SceneNode
5558
effects: [...effects],
5659
isMask: isMask,
5760
blendMode: blendMode,
61+
inkWell: inkWell,
5862
);
5963

6064
setGeometryMixin(
@@ -242,22 +246,27 @@ mixin BlendMixin on BaseNode {
242246
/// List of effects applied to the node.
243247
late List<Effect> effects;
244248

249+
/// Whether to use ink well on this node, along with its properties.
250+
late InkWellModel? inkWell;
251+
245252
/// Sets the blend properties of the node.
246253
void setBlendMixin({
247254
required double opacity,
248255
required bool isMask,
249256
required List<Effect> effects,
250257
required BlendModeC blendMode,
258+
required InkWellModel? inkWell,
251259
}) {
252260
this.opacity = opacity;
253261
this.isMask = isMask;
254262
this.effects = effects;
255263
this.blendMode = blendMode;
264+
this.inkWell = inkWell;
256265
}
257266

258267
@override
259268
String toString() =>
260-
"${super.toString()}\n Blend(${"opacity: $opacity, isMask: $isMask"})";
269+
"${super.toString()}\n Blend(${"opacity: $opacity, isMask: $isMask, effects: $effects, blendMode: $blendMode, inkWell: $inkWell"})";
261270
}
262271

263272
/// Represents the type of sizing a node can have on either axis.

lib/src/api/models/ink_well.dart

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright (c) 2022, Codelessly.
2+
// All rights reserved. Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE.md file.
4+
5+
import 'package:equatable/equatable.dart';
6+
import 'package:json_annotation/json_annotation.dart';
7+
8+
import '../../../codelessly_api.dart';
9+
10+
part 'ink_well.g.dart';
11+
12+
/// Represents properties that relate to the [InkWell] widget in Flutter.
13+
@JsonSerializable()
14+
class InkWellModel with EquatableMixin, SerializableMixin {
15+
16+
/// The highlight color of the [InkWell] if [useInkWell] is true.
17+
final ColorRGBA? highlightColor;
18+
19+
/// The splash color of the [InkWell] if [useInkWell] is true.
20+
final ColorRGBA? splashColor;
21+
22+
/// The hover color of the [InkWell] if [useInkWell] is true.
23+
final ColorRGBA? hoverColor;
24+
25+
/// The focus color of the [InkWell] if [useInkWell] is true.
26+
final ColorRGBA? focusColor;
27+
28+
/// Creates an [InkWellModel] instance with the given data.
29+
const InkWellModel({
30+
this.highlightColor,
31+
this.splashColor,
32+
this.hoverColor,
33+
this.focusColor,
34+
});
35+
36+
/// Duplicates this instance of [InkWellModel] with given useInkWell value.
37+
InkWellModel copyWithUseInkWell(bool value) => InkWellModel(
38+
highlightColor: highlightColor,
39+
splashColor: splashColor,
40+
hoverColor: hoverColor,
41+
focusColor: focusColor,
42+
);
43+
44+
/// Duplicates this instance of [InkWellModel] with given highlight color.
45+
InkWellModel copyWithHighlightColor(ColorRGBA? color) => InkWellModel(
46+
highlightColor: color,
47+
splashColor: splashColor,
48+
hoverColor: hoverColor,
49+
focusColor: focusColor,
50+
);
51+
52+
/// Duplicates this instance of [InkWellModel] with given splash color.
53+
InkWellModel copyWithSplashColor(ColorRGBA? color) => InkWellModel(
54+
highlightColor: highlightColor,
55+
splashColor: color,
56+
hoverColor: hoverColor,
57+
focusColor: focusColor,
58+
);
59+
60+
/// Duplicates this instance of [InkWellModel] with given hover color.
61+
InkWellModel copyWithHoverColor(ColorRGBA? color) => InkWellModel(
62+
highlightColor: highlightColor,
63+
splashColor: splashColor,
64+
hoverColor: color,
65+
focusColor: focusColor,
66+
);
67+
68+
/// Duplicates this instance of [InkWellModel] with given focus color.
69+
InkWellModel copyWithFocusColor(ColorRGBA? color) => InkWellModel(
70+
highlightColor: highlightColor,
71+
splashColor: splashColor,
72+
hoverColor: hoverColor,
73+
focusColor: color,
74+
);
75+
76+
/// Factory constructor for creating a new [InkWellModel] instance
77+
/// from JSON data.
78+
factory InkWellModel.fromJson(Map<String, dynamic> json) =>
79+
_$InkWellModelFromJson(json);
80+
81+
@override
82+
Map<String, dynamic> toJson() => _$InkWellModelToJson(this);
83+
84+
@override
85+
List<Object?> get props => [
86+
highlightColor,
87+
splashColor,
88+
hoverColor,
89+
focusColor,
90+
];
91+
}

lib/src/api/models/ink_well.g.dart

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/models/models.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export 'font_name.dart';
3232
export 'google_maps.dart';
3333
export 'icon.dart';
3434
export 'icon_model.dart';
35+
export 'ink_well.dart';
3536
export 'input_border.dart';
3637
export 'input_decoration.dart';
3738
export 'letter_spacing.dart';

lib/src/api/nodes/accordion_node.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/app_bar_node.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/auto_placeholder_node.g.dart

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/button_node.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/canvas_node.g.dart

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/checkbox_node.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)