Skip to content

Commit

Permalink
Fix pr issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kawaijoe committed Jul 16, 2024
1 parent c24e013 commit 0459bd5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 30 deletions.
8 changes: 4 additions & 4 deletions docs/pages/docs/bottom-navigation-bar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ It is used to navigate between a small number of views, typically between three
@override
Widget build(BuildContext context) => FBottomNavigationBar(
activeIndex: index,
onSelect: (index) => setState(() => this.index = index),
index: index,
onChange: (index) => setState(() => this.index = index),
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down Expand Up @@ -65,8 +65,8 @@ It is used to navigate between a small number of views, typically between three

```dart
FBottomNavigationBar(
activeIndex: 0,
onSelect: (index) => {},
index: 0,
onChange: (index) => {},
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/scaffold.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ Creates a visual scaffold for Forui widgets.
header: headers[index],
content: contents[index],
footer: FBottomNavigationBar(
activeIndex: index,
onSelect: (index) => setState(() => this.index = index),
index: index,
onChange: (index) => setState(() => this.index = index),
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down
4 changes: 2 additions & 2 deletions forui/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class _ApplicationState extends State<Application> {
),
content: child ?? const SizedBox(),
footer: FBottomNavigationBar(
activeIndex: index,
onSelect: (index) => setState(() => this.index = index),
index: index,
onChange: (index) => setState(() => this.index = index),
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ class FBottomNavigationBar extends StatelessWidget {
final List<Widget> items;

/// A callback for when an item is selected.
final ValueChanged<int>? onSelect;
final ValueChanged<int>? onChange;

/// Creates a [FBottomNavigationBar] with [FBottomNavigationBarItem]s.
FBottomNavigationBar({
required List<FBottomNavigationBarItem> items,
this.style,
this.onSelect,
int activeIndex = -1,
this.onChange,
int index = -1,
super.key,
}) : items = items
.mapIndexed(
(index, item) => _FBottomNavigationBarWidget(
(currentIndex, item) => _FBottomNavigationBarItem(
item: item,
active: index == activeIndex,
current: index == currentIndex,
style: style?.item,
),
)
Expand All @@ -48,7 +48,7 @@ class FBottomNavigationBar extends StatelessWidget {
const FBottomNavigationBar.raw({
required this.items,
this.style,
this.onSelect,
this.onChange,
super.key,
});

Expand All @@ -72,9 +72,7 @@ class FBottomNavigationBar extends StatelessWidget {
(index, item) => Expanded(
child: FTappable(
child: item,
onTap: () {
onSelect?.call(index);
},
onTap: () => onChange?.call(index),
),
),
)
Expand All @@ -91,7 +89,7 @@ class FBottomNavigationBar extends StatelessWidget {
properties
..add(DiagnosticsProperty('style', style))
..add(IterableProperty('items', items))
..add(ObjectFlagProperty.has('onSelect', onSelect));
..add(ObjectFlagProperty.has('onSelect', onChange));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
part of 'bottom_navigation_bar.dart';

class _FBottomNavigationBarWidget extends StatelessWidget {
class _FBottomNavigationBarItem extends StatelessWidget {
final FBottomNavigationBarItemStyle? style;

final FBottomNavigationBarItem item;

final bool active;
final bool current;

const _FBottomNavigationBarWidget({
const _FBottomNavigationBarItem({
required this.item,
required this.active,
required this.current,
this.style,
});

Expand All @@ -27,15 +27,15 @@ class _FBottomNavigationBarWidget extends StatelessWidget {
item.icon(
height: style.iconSize,
colorFilter: ColorFilter.mode(
active ? style.activeIconColor : style.inactiveIconColor,
current ? style.activeIconColor : style.inactiveIconColor,
BlendMode.srcIn,
),
),
const SizedBox(height: 2),
Text(
item.label,
overflow: TextOverflow.ellipsis,
style: active ? style.activeTextStyle : style.inactiveTextStyle,
style: current ? style.activeTextStyle : style.inactiveTextStyle,
),
],
),
Expand All @@ -49,7 +49,7 @@ class _FBottomNavigationBarWidget extends StatelessWidget {
properties
..add(DiagnosticsProperty('style', style))
..add(DiagnosticsProperty('item', item))
..add(FlagProperty('active', value: active, ifTrue: 'active'));
..add(FlagProperty('active', value: current, ifTrue: 'active'));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() {
data: theme,
background: background,
child: FBottomNavigationBar(
activeIndex: 2,
index: 2,
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down
4 changes: 2 additions & 2 deletions samples/lib/widgets/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class _DemoState extends State<_Demo> {

@override
Widget build(BuildContext context) => FBottomNavigationBar(
activeIndex: index,
onSelect: (index) => setState(() => this.index = index),
index: index,
onChange: (index) => setState(() => this.index = index),
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down
4 changes: 2 additions & 2 deletions samples/lib/widgets/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class _DemoState extends State<_Demo> {
header: headers[index],
content: contents[index],
footer: FBottomNavigationBar(
activeIndex: index,
onSelect: (index) => setState(() => this.index = index),
index: index,
onChange: (index) => setState(() => this.index = index),
items: [
FBottomNavigationBarItem(
icon: FAssets.icons.home,
Expand Down

0 comments on commit 0459bd5

Please sign in to comment.