Skip to content

Commit

Permalink
Alert ready for review
Browse files Browse the repository at this point in the history
  • Loading branch information
Daviiddoo committed Jul 16, 2024
1 parent 733892b commit b18be8a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 19 deletions.
64 changes: 64 additions & 0 deletions docs/pages/docs/alert.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Tabs } from 'nextra/components';
import { Widget } from "../../components/widget";

# Alert
Displays a callout for user attention.

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='alert' query={{}}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FAlert(
title: const Text('Heads Up!'),
subtitle: const Text('You can add components to your app using the cli.'),
),
```
</Tabs.Tab>
</Tabs>

## Usage

### `FAlert(...)`

```dart
FAlert(
icon: FAssets.icons.badgeAlert,
title: const Text('Heads Up!'),
subtitle: const Text('You can add components to your app using the cli.'),
),
```

## Examples

### Primary
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='alert' query={{}}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FAlert(
title: const Text('Heads Up!'),
subtitle: const Text('You can add components to your app using the cli.'),
),
```
</Tabs.Tab>
</Tabs>

### Destructive
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='alert' query={{style: 'destructive'}}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
FAlert(
title: const Text('Heads Up!'),
subtitle: const Text('You can add components to your app using the cli.'),
style: FAlertStyle.destructive,
),
```
</Tabs.Tab>
</Tabs>
6 changes: 3 additions & 3 deletions forui/example/lib/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class _ExampleState extends State<Example> {
const SizedBox(height: 100),
FProgress(value: 0.9),
const SizedBox(height: 10),
FAlert(
title: const Text('Heads Up! Forui is coming to flutter!'),
subtitle: const Text('You can add components dfijsoi djfosfj to your app using the cli.'),
const FAlert(
title: Text('Heads Up! Forui is coming to flutter!'),
subtitle: Text('You can add components dfijsoi djfosfj to your app using the cli.'),
)
],
);
Expand Down
22 changes: 12 additions & 10 deletions forui/lib/src/widgets/alert/alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FAlert extends StatelessWidget {
final SvgAsset? icon;

/// The title.
final Widget? title;
final Widget title;

/// The subtitle.
final Widget? subtitle;
Expand All @@ -38,8 +38,8 @@ class FAlert extends StatelessWidget {
/// |---------------------------|
/// ```
const FAlert({
required this.title,
this.icon,
this.title,
this.subtitle,
this.style = Variant.primary,
super.key,
Expand Down Expand Up @@ -72,16 +72,16 @@ class FAlert extends StatelessWidget {
padding: const EdgeInsets.only(left: 8),
child: DefaultTextStyle.merge(
style: style.titleTextStyle,
child: title!,
child: title,
),
),
),
],
),
Row(
children: [
SizedBox(width: style.iconSize),
if (subtitle != null)
if (subtitle != null)
Row(
children: [
SizedBox(width: style.iconSize),
Flexible(
child: Padding(
padding: const EdgeInsets.only(top: 3, left: 8),
Expand All @@ -91,8 +91,8 @@ class FAlert extends StatelessWidget {
),
),
),
],
),
],
),
],
),
),
Expand All @@ -102,7 +102,9 @@ class FAlert extends StatelessWidget {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty('style', style));
properties
..add(DiagnosticsProperty('style', style))
..add(DiagnosticsProperty('icon', icon));
}
}

Expand Down
4 changes: 2 additions & 2 deletions forui/lib/src/widgets/alert/alert_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FAlertStyles with Diagnosticable {
: primary = FAlertCustomStyle(
iconSize: 20,
iconColor: colorScheme.foreground,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
titleTextStyle: typography.base.copyWith(
fontWeight: FontWeight.w500,
color: colorScheme.foreground,
Expand All @@ -36,7 +36,7 @@ class FAlertStyles with Diagnosticable {
destructive = FAlertCustomStyle(
iconSize: 20,
iconColor: colorScheme.destructive,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 16),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
titleTextStyle: typography.base.copyWith(
fontWeight: FontWeight.w500,
color: colorScheme.destructive,
Expand Down
8 changes: 4 additions & 4 deletions samples/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class _AppRouter extends $_AppRouter {
page: EmptyRoute.page,
initial: true,
),
AutoRoute(
path: '/alert/default',
page: AlertRoute.page,
),
AutoRoute(
path: '/alert/default',
page: AlertRoute.page,
),
AutoRoute(
path: '/badge/default',
page: BadgeRoute.page,
Expand Down

0 comments on commit b18be8a

Please sign in to comment.