Skip to content

Commit

Permalink
Nested header (#57)
Browse files Browse the repository at this point in the history
* Implement nested header

* Add tests

* Add documentation

* Commit from GitHub Actions (Forui Presubmit)

* Refactor code to use Header.nested()

* Refactor code to use FHeader.nested()

* Implement nested header

* Add tests

* Add documentation

* Commit from GitHub Actions (Forui Presubmit)

* Refactor code to use Header.nested()

* Commit from GitHub Actions (Forui Samples Presubmit)

* Fix pr issues

* Apply suggestions from code review

Co-authored-by: Matthias Ngeo <[email protected]>

---------

Co-authored-by: Matthias Ngeo <[email protected]>
  • Loading branch information
kawaijoe and Pante authored Jun 30, 2024
1 parent 64b3aa4 commit 9d1c341
Show file tree
Hide file tree
Showing 29 changed files with 817 additions and 329 deletions.
8 changes: 0 additions & 8 deletions .idea/runConfigurations/forui___update_golden_test_images.xml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/runConfigurations/samples___run.xml

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

3 changes: 1 addition & 2 deletions docs/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
NEXT_PUBLIC_DEMO_URL=https://dev.demo.forui.dev
NEXT_PUBLIC_DEMO_URL=http://localhost:51624
NEXT_PUBLIC_DEMO_URL=http://localhost:3001
4 changes: 2 additions & 2 deletions docs/components/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ interface Props {
name: string;
variant?: string;
height?: number;
query: Record<string, string>;
query?: Record<string, string>;
}

export function Widget({name, variant = 'default', height = 200, query}: Props) {
export function Widget({name, variant = 'default', height = 200, query = {}}: Props) {
const {resolvedTheme} = useTheme();
query['theme'] = `zinc-${resolvedTheme}`;

Expand Down
3 changes: 2 additions & 1 deletion docs/pages/docs/button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ FButton(
```dart
FButton.raw(
child: Text('Button'),
onPress: () {};
onPress: () {},
);
```

## Examples

### Primary
Expand Down
141 changes: 135 additions & 6 deletions docs/pages/docs/header.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { Widget } from "../../components/widget";

# Header
A header contains the page's title and navigation actions.
It is typically used on pages at the root of the navigation stack.

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='header' query={{}}/>
<Widget name='header'/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FHeader(
title: 'Edit Alarm',
title: const Text('Edit Alarm'),
actions: [
FHeaderAction(
icon: FAssets.icons.alarmClock,
Expand All @@ -22,18 +23,48 @@ A header contains the page's title and navigation actions.
onPress: () {},
),
],
)
);
```
</Tabs.Tab>
</Tabs>

## Nested Header

It is typically used on nested pages or sheets.

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='header' variant='nested'/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FHeader.nested(
title: const Text('Appointment'),
leftActions: [
FHeaderAction.back(onPress: () {}),
],
rightActions: [
FHeaderAction(
icon: FAssets.icons.info,
onPress: () {},
),
FHeaderAction(
icon: FAssets.icons.plus,
onPress: () {},
),
],
);
```
</Tabs.Tab>
</Tabs>

## Usage

### `FHeader(...)`

```dart
FHeader(
title: 'Edit Alarm',
title: const Text('Title'),
actions: [
FHeaderAction(
icon: FAssets.icons.alarmClock,
Expand All @@ -44,5 +75,103 @@ FHeader(
onPress: () {},
),
],
)
```
);
```

### `FHeader.nested(...)`

```dart
FHeader.nested(
title: const Text('Title'),
leftActions: [
FHeaderAction.back(onPress: () {}),
],
rightActions: [
FHeaderAction(
icon: FAssets.icons.info,
onPress: () {},
),
FHeaderAction.x(onPress: () {}),
],
);
```

## Examples

### Header
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='header'/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FHeader(
title: const Text('Edit Alarm'),
actions: [
FHeaderAction(
icon: FAssets.icons.alarmClock,
onPress: () {},
),
FHeaderAction(
icon: FAssets.icons.plus,
onPress: () {},
),
],
);
```
</Tabs.Tab>
</Tabs>

### Nested Header with back icon
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='header' variant='nested' />
</Tabs.Tab>
<Tabs.Tab>
```dart
FHeader.nested(
title: const Text('Appointment'),
leftActions: [
FHeaderAction.back(onPress: () {}),
],
rightActions: [
FHeaderAction(
icon: FAssets.icons.info,
onPress: () {},
),
FHeaderAction(
icon: FAssets.icons.plus,
onPress: () {},
),
],
);
```
</Tabs.Tab>
</Tabs>

### Nested Header with X icon
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='header' variant='nested-x' />
</Tabs.Tab>
<Tabs.Tab>
```dart
FHeader.nested(
title: const Text('Climate'),
leftActions: [
FHeaderAction(
icon: FAssets.icons.thermometer,
onPress: () {},
),
FHeaderAction(
icon: FAssets.icons.wind,
onPress: null,
),
],
rightActions: [
FHeaderAction.x(onPress: () {}),
],
);
```
</Tabs.Tab>
</Tabs>
4 changes: 2 additions & 2 deletions docs/pages/docs/scaffold.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Creates a visual scaffold for Forui widgets.
```dart
FScaffold(
header: FHeader(
title: 'Settings',
title: const Text('Settings'),
actions: [
FHeaderAction(
icon: FAssets.icons.ellipsis,
Expand Down Expand Up @@ -63,7 +63,7 @@ Creates a visual scaffold for Forui widgets.
```dart
FScaffold(
header: FHeader(
title: 'Settings',
title: const Text('Settings'),
actions: [
FHeaderAction(
icon: FAssets.icons.ellipsis,
Expand Down
10 changes: 10 additions & 0 deletions forui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.2.0

* Add `Header.nested` widget.

### Breaking changes

* `FHeaderStyle` have been nested in `FHeaderStyles.rootStyle`.
* `FHeaderActionStyle.action` parameter has been renamed to `FRootHeaderStyle.actionStyle`.
* `FHeaderActionStyle.padding` parameter has been moved to `FRootHeaderStyle.actionSpacing`.

## 0.1.0

* Initial release! 🚀
62 changes: 62 additions & 0 deletions forui/example/lib/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';

import 'package:forui/forui.dart';

class Example extends StatefulWidget {
const Example({super.key});

@override
State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 10),
Expanded(
child: FTabs(
tabs: [
FTabEntry(
label: 'Account',
content: FCard(
title: 'Account',
subtitle: 'Make changes to your account here. Click save when you are done.',
child: Column(
children: [
Container(
color: Colors.red,
height: 100,
),
],
),
),
),
FTabEntry(
label: 'Password',
content: FCard(
title: 'Password',
subtitle: 'Change your password here. After saving, you will be logged out.',
child: Column(
children: [
Container(
color: Colors.blue,
height: 100,
)
],
),
),
),
],
),
),
],
);
}
Loading

0 comments on commit 9d1c341

Please sign in to comment.