-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/avatar
- Loading branch information
Showing
45 changed files
with
2,255 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ migrate_working_dir/ | |
.flutter-plugins-dependencies | ||
build/ | ||
test/golden/failures/ | ||
test/**/*_test.mocks.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
## Next | ||
|
||
### Additions | ||
* Add `FResizable` | ||
|
||
|
||
## 0.3.0 | ||
|
||
### Additions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ dependencies: | |
sdk: flutter | ||
forui: | ||
path: ../ | ||
intl: ^0.19.0 | ||
sugar: ^3.1.0 | ||
|
||
dev_dependencies: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.