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

Removed raw parameters #68

Merged
merged 5 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 0 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,6 @@ They should:
5. implement `operator ==` and `hashCode`.


## Expose `String` and `Widget` variants of the same parameter.

Widgets typically contain string-based content such as titles and labels. These widgets should expose a `String` and
`Widget` variant of the same parameter. For example, a widget that has a title should expose `String? label` and `Widget?
rawLabel` constructor parameters. The constructor should then assert that only one of these parameters is non-null.

[Example](https://github.com/forus-labs/forui/blob/e61a11a346e8e1d788ba2eb9031b73a18a407402/forui/lib/src/widgets/badge/badge.dart#L20):
```dart
FBadge({
String? label,
Widget? rawLabel,
}) :
assert((label == null) ^ (rawLabel == null), 'Either "label" or "rawLabel" must be provided, but not both.'),
```


## Conventions

* Avoid [double negatives](https://en.wikipedia.org/wiki/Double_negative) when naming things, i.e. a boolean field should
Expand Down
12 changes: 6 additions & 6 deletions docs/pages/docs/badge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A badge typically draws attention to specific information, such as labels and co
</Tabs.Tab>
<Tabs.Tab>
```dart
FBadge(label: 'Badge');
FBadge(label: const Text('Badge'));
```
</Tabs.Tab>
</Tabs>
Expand All @@ -20,7 +20,7 @@ A badge typically draws attention to specific information, such as labels and co
### `FBadge(...)`

```dart
FBadge(label: 'Badge');
FBadge(label: const Text('Badge'));
```

### `FBadge.raw(...)`
Expand All @@ -37,7 +37,7 @@ FBadge.raw(builder: (context, style) => Text('Badge'));
</Tabs.Tab>
<Tabs.Tab>
```dart
FBadge(label: 'Badge');
FBadge(label: const Text('Badge'));
```
</Tabs.Tab>
</Tabs>
Expand All @@ -50,7 +50,7 @@ FBadge.raw(builder: (context, style) => Text('Badge'));
<Tabs.Tab>
```dart
FBadge(
label: 'Badge',
label: const Text('Badge'),
style: FBadgeStyle.secondary,
);
```
Expand All @@ -65,7 +65,7 @@ FBadge.raw(builder: (context, style) => Text('Badge'));
<Tabs.Tab>
```dart
FBadge(
label: 'Badge',
label: const Text('Badge'),
style: FBadgeStyle.outline,
);
```
Expand All @@ -80,7 +80,7 @@ FBadge.raw(builder: (context, style) => Text('Badge'));
<Tabs.Tab>
```dart
FBadge(
label: 'Badge',
label: const Text('Badge'),
style: FBadgeStyle.destructive,
);
```
Expand Down
18 changes: 9 additions & 9 deletions docs/pages/docs/button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A button.
<Tabs.Tab>
```dart
FButton(
label: 'Button',
label: const Text('Button'),
onPress: () {},
);
```
Expand All @@ -24,7 +24,7 @@ A button.

```dart
FButton(
label: 'Button',
label: const Text('Button'),
onPress: () {},
);
```
Expand All @@ -33,7 +33,7 @@ FButton(

```dart
FButton.raw(
child: Text('Button'),
child: const Text('Button'),
onPress: () {},
);
```
Expand All @@ -48,7 +48,7 @@ FButton.raw(
<Tabs.Tab>
```dart
FButton(
label: 'Button',
label: const Text('Button'),
onPress: () {},
);
```
Expand All @@ -63,7 +63,7 @@ FButton.raw(
<Tabs.Tab>
```dart
FButton(
label: 'Button',
label: const Text('Button'),
style: FButtonStyle.secondary,
onPress: () {},
);
Expand All @@ -79,7 +79,7 @@ FButton.raw(
<Tabs.Tab>
```dart
FButton(
label: 'Button',
label: const Text('Button'),
style: FButtonStyle.outline,
onPress: () {},
);
Expand All @@ -95,7 +95,7 @@ FButton.raw(
<Tabs.Tab>
```dart
FButton(
label: 'Button',
label: const Text('Button'),
style: FButtonStyle.destructive,
onPress: () {},
);
Expand All @@ -111,8 +111,8 @@ FButton.raw(
<Tabs.Tab>
```dart
FButton(
prefixIcon: FButtonIcon(icon: FAssets.icons.mail),
label: 'Login with Email',
prefix: FButtonIcon(icon: FAssets.icons.mail),
label: const Text('Login with Email'),
onPress: () {},
),
```
Expand Down
10 changes: 5 additions & 5 deletions docs/pages/docs/card.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ A card, typically with a title, subtitle, and child widget.
<Tabs.Tab>
```dart
FCard(
title: 'Notification',
subtitle: 'You have 3 unread messages.',
title: const Text('Notification'),
subtitle: const Text('You have 3 unread messages.'),
);
```
</Tabs.Tab>
Expand All @@ -24,9 +24,9 @@ A card, typically with a title, subtitle, and child widget.

```dart
FCard(
title: 'Notification',
subtitle: 'You have 3 unread messages.',
child: FButton(label: 'Read messages', onPress: () {}),
title: const Text('Notification'),
subtitle: const Text('You have 3 unread messages.'),
child: FButton(label: const Text('Read messages'), onPress: () {}),
);
```

Expand Down
38 changes: 19 additions & 19 deletions docs/pages/docs/dialog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ A modal dialog interrupts the user with important content and expects a response
children: [
IntrinsicWidth(
child: FButton(
label: 'Show Dialog',
label: const Text('Show Dialog'),
onPress: () => showAdaptiveDialog(
context: context,
builder: (context) => FDialog(
direction: Axis.horizontal,
title: 'Are you absolutely sure?',
body: 'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
title: const Text('Are you absolutely sure?'),
body: const Text('This action cannot be undone. This will permanently delete your account and remove your data from our servers.'),
actions: [
FButton(style: FButtonStyle.outline, label: 'Cancel', onPress: () => Navigator.of(context).pop()),
FButton(label: 'Continue', onPress: () => Navigator.of(context).pop()),
FButton(style: FButtonStyle.outline, label: const Text('Cancel'), onPress: () => Navigator.of(context).pop()),
FButton(label: const Text('Continue'), onPress: () => Navigator.of(context).pop()),
],
),
),
Expand All @@ -43,11 +43,11 @@ A modal dialog interrupts the user with important content and expects a response
```dart
FDialog(
direction: Axis.horizontal,
title: 'Are you absolutely sure?',
body: 'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
title: const Text('Are you absolutely sure?'),
body: const Text('This action cannot be undone. This will permanently delete your account and remove your data from our servers.'),
actions: [
FButton(style: FButtonStyle.outline, label: 'Cancel', onPress: () => Navigator.of(context).pop()),
FButton(label: 'Continue', onPress: () => Navigator.of(context).pop()),
FButton(style: FButtonStyle.outline, label: const Text('Cancel'), onPress: () => Navigator.of(context).pop()),
FButton(label: const Text('Continue'), onPress: () => Navigator.of(context).pop()),
],
);
```
Expand All @@ -74,16 +74,16 @@ FDialog.raw(
children: [
IntrinsicWidth(
child: FButton(
label: 'Show Dialog',
label: const Text('Show Dialog'),
onPress: () => showAdaptiveDialog(
context: context,
builder: (context) => FDialog(
direction: Axis.horizontal,
title: 'Are you absolutely sure?',
body: 'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
title: const Text('Are you absolutely sure?'),
body: const Text('This action cannot be undone. This will permanently delete your account and remove your data from our servers.'),
actions: [
FButton(style: FButtonStyle.outline, label: 'Cancel', onPress: () => Navigator.of(context).pop()),
FButton(label: 'Continue', onPress: () => Navigator.of(context).pop()),
FButton(style: FButtonStyle.outline, label: const Text('Cancel'), onPress: () => Navigator.of(context).pop()),
FButton(label: const Text('Continue'), onPress: () => Navigator.of(context).pop()),
],
),
),
Expand All @@ -108,16 +108,16 @@ FDialog.raw(
children: [
IntrinsicWidth(
child: FButton(
label: 'Show Dialog',
label: const Text('Show Dialog'),
onPress: () => showAdaptiveDialog(
context: context,
builder: (context) => FDialog(
direction: Axis.vertical,
title: 'Are you absolutely sure?',
body: 'This action cannot be undone. This will permanently delete your account and remove your data from our servers.',
title: const Text('Are you absolutely sure?'),
body: const Text('This action cannot be undone. This will permanently delete your account and remove your data from our servers.'),
actions: [
FButton(label: 'Continue', onPress: () => Navigator.of(context).pop()),
FButton(style: FButtonStyle.outline, label: 'Cancel', onPress: () => Navigator.of(context).pop()),
FButton(label: const Text('Continue'), onPress: () => Navigator.of(context).pop()),
FButton(style: FButtonStyle.outline, label: const Text('Cancel'), onPress: () => Navigator.of(context).pop()),
],
),
),
Expand Down
16 changes: 8 additions & 8 deletions docs/pages/docs/scaffold.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ Creates a visual scaffold for Forui widgets.
content: ListView(
children: [
FCard(
title: 'Account',
subtitle: 'Make changes to your account here. Click save when you are done.',
title: const Text('Account'),
subtitle: const Text('Make changes to your account here. Click save when you are done.'),
child: Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(
children: [
const FTextField(
label: 'Name',
label: Text('Name'),
hint: 'John Renalo',
),
const SizedBox(height: 10),
const FTextField(
label: 'Email',
label: Text('Email'),
hint: '[email protected]',
),
Padding(
padding: const EdgeInsets.only(top: 24, bottom: 16),
child: FButton(
label: 'Save',
label: const Text('Save'),
onPress: () {},
),
),
Expand Down Expand Up @@ -75,9 +75,9 @@ FScaffold(
content: Column(
children: [
FCard(
title: 'Notification',
subtitle: 'You have 3 unread messages.',
child: FButton(label: 'Read messages', onPress: () {}),
title: const Text('Notification'),
subtitle: const Text('You have 3 unread messages.'),
child: FButton(label: const Text('Read messages'), onPress: () {}),
),
],
),
Expand Down
30 changes: 15 additions & 15 deletions docs/pages/docs/tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ A set of layered sections of content—known as tab entries—that are displayed
child: FTabs(
tabs: [
FTabEntry(
label: 'Account',
label: const Text('Account'),
content: FCard(
title: 'Account',
subtitle: 'Make changes to your account here. Click save when you are done.',
title: const Text('Account'),
subtitle: const Text('Make changes to your account here. Click save when you are done.'),
child: Padding(
padding: const EdgeInsets.only(top: 12),
child: Column(
children: [
const FTextField(
label: 'Name',
label: Text('Name'),
hint: 'John Renalo',
),
const SizedBox(height: 10),
const FTextField(
label: 'Email',
label: Text('Email'),
hint: '[email protected]',
),
Padding(
padding: const EdgeInsets.only(top: 24, bottom: 16),
child: FButton(
label: 'Save',
label: const Text('Save'),
onPress: () {},
),
),
Expand All @@ -45,21 +45,21 @@ A set of layered sections of content—known as tab entries—that are displayed
),
),
FTabEntry(
label: 'Password',
label: const Text(Password'),
content: FCard(
title: 'Password',
subtitle: 'Change your password here. After saving, you will be logged out.',
title: const Text('Password'),
subtitle: const Text('Change your password here. After saving, you will be logged out.'),
child: Padding(
padding: const EdgeInsets.only(top: 12),
child: Column(
children: [
const FTextField(label: 'Current password'),
const FTextField(label: Text('Current password')),
const SizedBox(height: 10),
const FTextField(label: 'New password'),
const FTextField(label: Text('New password')),
Padding(
padding: const EdgeInsets.only(top: 24, bottom: 16),
child: FButton(
label: 'Save',
label: const Text('Save'),
onPress: () {},
),
),
Expand All @@ -82,9 +82,9 @@ A set of layered sections of content—known as tab entries—that are displayed
```dart
FTabs(
initialIndex: 1,
tabs: [
FTabEntry(label: 'Account', content: FCard()),
FTabEntry(label: 'Password', content: FCard()),
tabs: const [
FTabEntry(label: Text('Account'), content: Placeholder()),
FTabEntry(label: Text('Password'), content: Placeholder()),
],
onPress: (index) {},
);
Expand Down
Loading
Loading