Skip to content

Commit

Permalink
feat: add nes blinker (#108)
Browse files Browse the repository at this point in the history
* feat: adding blinker

* examples and changelog

* examples and changelog

* fix lint
  • Loading branch information
erickzanardo authored Dec 21, 2023
1 parent 3105504 commit de24539
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.12.0
- feat: adding `NesBlinker`.

# 0.11.0
- feat: add ability to customize `NesContainer`s pixel sizes.
- feat: add ability to customize `NesButton`s pixel sizes.
Expand Down
2 changes: 2 additions & 0 deletions example/lib/gallery/gallery_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class GalleryPage extends StatelessWidget {
const SizedBox(height: 32),
const RunningTextSection(),
const SizedBox(height: 32),
const EffectsSection(),
const SizedBox(height: 32),
const LoadingIndicatorsSection(),
const SizedBox(height: 32),
const TooltipsSection(),
Expand Down
31 changes: 31 additions & 0 deletions example/lib/gallery/sections/effects.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:nes_ui/nes_ui.dart';

class EffectsSection extends StatelessWidget {
const EffectsSection({super.key});

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Effects',
style: theme.textTheme.displayMedium,
),
const SizedBox(height: 16),
Wrap(
children: [
SizedBox(
height: 40,
child: NesBlinker(
child: const Text('NES Blinker'),
),
),
],
),
],
);
}
}
1 change: 1 addition & 0 deletions example/lib/gallery/sections/sections.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export 'containers.dart';
export 'custom_extensions.dart';
export 'dialogs.dart';
export 'drop_shadows.dart';
export 'effects.dart';
export 'file_explorer.dart';
export 'icon_badges.dart';
export 'icon_buttons.dart';
Expand Down
30 changes: 30 additions & 0 deletions lib/src/widgets/nes_blinker.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:phased/phased.dart';

/// {@template nes_blinker}
/// A widget that blinks its child.
/// {@endtemplate}
class NesBlinker extends Phased<bool> {
/// {@macro nes_blinker}
NesBlinker({
super.key,
required this.child,
}) : super(
state: PhasedState<bool>(
values: [true, false],
ticker: const Duration(seconds: 1),
),
);

/// The child widget to blink.
final Widget child;

@override
Widget build(BuildContext context) {
if (state.value) {
return child;
} else {
return const SizedBox();
}
}
}
26 changes: 1 addition & 25 deletions lib/src/widgets/nes_selection_list.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:nes_ui/nes_ui.dart';
import 'package:phased/phased.dart';

/// {@template nes_selection_list}
///
Expand Down Expand Up @@ -219,29 +218,6 @@ class _NesSelectionListState extends State<NesSelectionList> {
}
}

class _Blinker extends Phased<bool> {
_Blinker({
super.key,
required this.child,
}) : super(
state: PhasedState<bool>(
values: [true, false],
ticker: const Duration(seconds: 1),
),
);

final Widget child;

@override
Widget build(BuildContext context) {
if (state.value) {
return child;
} else {
return const SizedBox();
}
}
}

class _SelectionItem extends StatelessWidget {
const _SelectionItem({
required this.markerKey,
Expand Down Expand Up @@ -270,7 +246,7 @@ class _SelectionItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final itemMarker = cursor && hasFocus
? _Blinker(
? NesBlinker(
key: markerKey,
child: marker,
)
Expand Down
1 change: 1 addition & 0 deletions lib/src/widgets/widgets.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export 'dialogs/dialogs.dart';
export 'nes_blinker.dart';
export 'nes_button.dart';
export 'nes_check_box.dart';
export 'nes_container.dart';
Expand Down

0 comments on commit de24539

Please sign in to comment.