Skip to content

Commit

Permalink
Merge branch 'main' into feature/avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
Daviiddoo committed Jul 23, 2024
2 parents 30e361e + 199ba0f commit bfe7eb0
Show file tree
Hide file tree
Showing 45 changed files with 2,255 additions and 48 deletions.
13 changes: 13 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
"automerge": true
},

{
"groupName": "Docs - Major Revisions",
"matchPaths": ["docs/**"],
"matchUpdateTypes": ["major"],
"automerge": false
},
{
"groupName": "Docs - Minor Revisions",
"matchPaths": ["docs/**"],
"matchUpdateTypes": ["minor", "patch", "pin", "digest"],
"automerge": true
},

{
"groupName": "Forui - Major Revisions",
"matchPaths": ["forui/**"],
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"homepage": "https://forui.dev",
"dependencies": {
"lucide-react": "^0.383.0",
"lucide-react": "^0.414.0",
"next": "^13.5.6",
"nextra": "^2.13.4",
"nextra-theme-docs": "^2.13.4",
Expand Down
186 changes: 186 additions & 0 deletions docs/pages/docs/resizable.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import { Tabs } from 'nextra/components';
import { Widget } from "../../components/widget";

# Resizable box
A box which children can be resized along either the horizontal or vertical axis.

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='resizable' query={{}} height={700}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
class TimeOfDay extends StatelessWidget {
@override
Widget build(BuildContext context) => FResizable(
axis: Axis.vertical,
crossAxisExtent: 400,
interaction: const FResizableRegionInteraction.selectAndResize(0),
children: [
FResizableRegion.raw(
initialSize: 200,
minSize: 100,
builder: (context, data, _) {
final colorScheme = context.theme.colorScheme;
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: data.selected ? colorScheme.foreground : colorScheme.background,
borderRadius: const BorderRadius.vertical(top: Radius.circular(8)),
border: Border.all(color: colorScheme.border),
),
child: Label(data: data, icon: FAssets.icons.sunrise, label: 'Morning'),
);
},
),
FResizableRegion.raw(
initialSize: 200,
minSize: 100,
builder: (context, data, _) {
final colorScheme = context.theme.colorScheme;
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: data.selected ? colorScheme.foreground : colorScheme.background,
border: Border.all(color: colorScheme.border),
),
child: Label(data: data, icon: FAssets.icons.sun, label: 'Afternoon'),
);
},
),
FResizableRegion.raw(
initialSize: 200,
minSize: 100,
builder: (context, data, _) {
final colorScheme = context.theme.colorScheme;
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: data.selected ? colorScheme.foreground : colorScheme.background,
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)),
border: Border.all(color: colorScheme.border),
),
child: Label(data: data, icon: FAssets.icons.moon, label: 'Night'),
);
},
),
],
);
}
class Label extends StatelessWidget {
static final DateFormat format = DateFormat.jm(); // Requires package:intl
final FResizableRegionData data;
final SvgAsset icon;
final String label;
const Label({required this.data, required this.icon, required this.label, super.key});
@override
Widget build(BuildContext context) {
final FThemeData(:colorScheme, :typography) = context.theme;
final color = data.selected ? colorScheme.background : colorScheme.foreground;
final start =
DateTime.fromMillisecondsSinceEpoch((data.percentage.min * Duration.millisecondsPerDay).round(), isUtc: true);
final end =
DateTime.fromMillisecondsSinceEpoch((data.percentage.max * Duration.millisecondsPerDay).round(), isUtc: true);
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
icon(height: 15, colorFilter: ColorFilter.mode(color, BlendMode.srcIn)),
const SizedBox(width: 3),
Text(label, style: typography.sm.copyWith(color: color)),
],
),
const SizedBox(height: 5),
Text('${format.format(start)} - ${format.format(end)}', style: typography.sm.copyWith(color: color)),
],
);
}
}
```
</Tabs.Tab>
</Tabs>

## Usage

### `FResizable(...)`

```dart
FResizable(
axis: Axis.vertical,
crossAxisExtent: 400,
interaction: const FResizableRegionInteraction.selectAndResize(0),
children: [
FResizableRegion.raw(
initialSize: 200,
minSize: 100,
onPress: (index) {},
onResizeUpdate: (selected, neighbour) {},
onResizeEnd: (selected, neighbour) {},
builder: (context, data, child) => child!,
child: const Placeholder(),
),
],
);
```

## Examples

### Resize without selecting

<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='resizable' variant='horizontal' query={{}} height={400}/>
</Tabs.Tab>
<Tabs.Tab>
```dart
@override
Widget build(BuildContext context) => FResizable(
axis: Axis.horizontal,
crossAxisExtent: 300,
children: [
FResizableRegion.raw(
initialSize: 100,
minSize: 100,
builder: (context, data, _) {
final colorScheme = context.theme.colorScheme;
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: data.selected ? colorScheme.foreground : colorScheme.background,
borderRadius: const BorderRadius.vertical(top: Radius.circular(8)),
border: Border.all(color: colorScheme.border),
),
child: Text('Sidebar', style: context.theme.typography.sm)
);
},
),
FResizableRegion.raw(
initialSize: 300,
minSize: 100,
builder: (context, data, _) {
final colorScheme = context.theme.colorScheme;
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)),
border: Border.all(color: colorScheme.border),
),
child: Text('Content', style: context.theme.typography.sm),
);
},
),
],
);
```
</Tabs.Tab>
</Tabs>


12 changes: 6 additions & 6 deletions docs/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions forui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ migrate_working_dir/
.flutter-plugins-dependencies
build/
test/golden/failures/
test/**/*_test.mocks.dart
6 changes: 6 additions & 0 deletions forui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Next

### Additions
* Add `FResizable`


## 0.3.0

### Additions
Expand Down
17 changes: 1 addition & 16 deletions forui/example/lib/example.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';

import 'package:forui/forui.dart';

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

Expand All @@ -16,18 +14,5 @@ class _ExampleState extends State<Example> {
}

@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 100),
FProgress(value: 0.9),
const SizedBox(height: 10),
FAvatar(
image: const NetworkImage('https://picsum.photos/'),
placeholderBuilder: (_) => const Text('DC'),
),
const SizedBox(height: 20),
],
);
Widget build(BuildContext context) => const Placeholder();
}
4 changes: 2 additions & 2 deletions forui/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _ApplicationState extends State<Application> {
@override
Widget build(BuildContext context) => MaterialApp(
builder: (context, child) => FTheme(
data: FThemes.zinc.light,
data: FThemes.zinc.dark,
child: FScaffold(
header: FHeader(
title: const Text('Example'),
Expand All @@ -32,7 +32,7 @@ class _ApplicationState extends State<Application> {
),
],
),
content: child ?? const SizedBox(),
content: const Example(),
footer: FBottomNavigationBar(
index: index,
onChange: (index) => setState(() => this.index = index),
Expand Down
6 changes: 3 additions & 3 deletions forui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ packages:
dependency: transitive
description:
name: graphs
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
http:
dependency: transitive
description:
Expand All @@ -303,7 +303,7 @@ packages:
source: hosted
version: "4.0.2"
intl:
dependency: transitive
dependency: "direct main"
description:
name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
Expand Down
1 change: 1 addition & 0 deletions forui/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies:
sdk: flutter
forui:
path: ../
intl: ^0.19.0
sugar: ^3.1.0

dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/widgets/alert/alert_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class FAlertIconStyle with Diagnosticable {

/// Creates a [FButtonIconStyle].
///
/// ## Contract:
/// ## Contract
/// Throws [AssertionError] if:
/// * `height` <= 0.0
/// * `height` is Nan
Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/widgets/badge/badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ final class FBadgeCustomStyle with Diagnosticable implements FBadgeStyle {

/// The border width (thickness).
///
/// ## Contract:
/// ## Contract
/// Throws [AssertionError] if:
/// * `borderWidth` <= 0.0
/// * `borderWidth` is Nan
Expand Down
2 changes: 1 addition & 1 deletion forui/lib/src/widgets/button/button_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class FButtonIconStyle with Diagnosticable {

/// Creates a [FButtonIconStyle].
///
/// ## Contract:
/// ## Contract
/// Throws [AssertionError] if:
/// * `height` <= 0.0
/// * `height` is Nan
Expand Down
Loading

0 comments on commit bfe7eb0

Please sign in to comment.