Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested header #57

Merged
merged 16 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 9 additions & 0 deletions forui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.2.0

* Add `NestedHeader` widget.

### Breaking changes

* `FHeaderActionStyle.action` parameter has been renamed to `FHeaderStyle.actionStyle`.
* `FHeaderActionStyle.padding` parameter has been moved to `FHeaderStyle.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
Loading