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

Improve FResizable #128

Merged
merged 15 commits into from
Aug 1, 2024
359 changes: 247 additions & 112 deletions docs/pages/docs/resizable.mdx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions forui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Next

### Additions
* Add `FAvatar`
* Add `FAvatar`.
* **Breaking:** Add `FCalendarEntryStyle.focusedBorderColor`. This only affects users that customized `FCalendarEntryStyle`.
* Add `FResizable`
* Add `FResizable`.

### Changes
* Change number of years displayed per page in `FCalendar` from 12 to 15.
Expand Down
6 changes: 3 additions & 3 deletions forui/example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.foruslabs.forui.samples.samples;
PRODUCT_BUNDLE_IDENTIFIER = com.foruslabs.forui.example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -660,7 +660,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.foruslabs.forui.samples.samples;
PRODUCT_BUNDLE_IDENTIFIER = com.foruslabs.forui.example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -683,7 +683,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.foruslabs.forui.samples.samples;
PRODUCT_BUNDLE_IDENTIFIER = com.foruslabs.forui.example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
8 changes: 4 additions & 4 deletions forui/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand All @@ -24,6 +26,8 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -41,9 +45,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
80 changes: 75 additions & 5 deletions forui/example/lib/example.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'package:forui/forui.dart';
import 'package:intl/intl.dart';

class Example extends StatefulWidget {
const Example({super.key});
Expand All @@ -18,12 +19,81 @@ class _ExampleState extends State<Example> {
@override
Widget build(BuildContext context) => Column(
children: [
FCalendar(
controller: FCalendarValueController(),
initialType: FCalendarPickerType.yearMonth,
start: DateTime.utc(2000),
end: DateTime.utc(2030),
DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: context.theme.colorScheme.border),
borderRadius: BorderRadius.circular(8),
),
child: FResizable(
controller: FResizableController.cascade(),
axis: Axis.vertical,
divider: FResizableDivider.dividerThumb,
crossAxisExtent: 300,
children: [
FResizableRegion(
initialExtent: 200,
minExtent: 100,
builder: (_, data, __) => Label(data: data, icon: FAssets.icons.sunrise, label: 'Morning'),
),
FResizableRegion(
initialExtent: 200,
minExtent: 100,
builder: (_, data, __) => Label(data: data, icon: FAssets.icons.sun, label: 'Afternoon'),
),
FResizableRegion(
initialExtent: 200,
minExtent: 100,
builder: (_, data, __) => Label(data: data, icon: FAssets.icons.sunset, label: 'Evening'),
),
],
),
),
],
);
}

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 start = DateTime.fromMillisecondsSinceEpoch(
(data.offsetPercentage.min * Duration.millisecondsPerDay).round(),
isUtc: true,
);

final end = DateTime.fromMillisecondsSinceEpoch(
(data.offsetPercentage.max * Duration.millisecondsPerDay).round(),
isUtc: true,
);

return Align(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
icon(height: 15, colorFilter: ColorFilter.mode(colorScheme.foreground, BlendMode.srcIn)),
const SizedBox(width: 3),
Text(label, style: typography.sm.copyWith(color: colorScheme.foreground)),
],
),
const SizedBox(height: 5),
Text(
'${format.format(start)} - ${format.format(end)}',
style: typography.sm.copyWith(color: colorScheme.foreground),
),
],
),
);
}
}
8 changes: 4 additions & 4 deletions forui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -450,18 +450,18 @@ packages:
dependency: transitive
description:
name: path_provider
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161
sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378
url: "https://pub.dev"
source: hosted
version: "2.1.3"
version: "2.1.4"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "30c5aa827a6ae95ce2853cdc5fe3971daaac00f6f081c419c013f7f57bff2f5e"
sha256: "490539678396d4c3c0b06efdaab75ae60675c3e0c66f72bc04c2e2c1e0e2abeb"
url: "https://pub.dev"
source: hosted
version: "2.2.7"
version: "2.2.9"
path_provider_foundation:
dependency: transitive
description:
Expand Down
10 changes: 10 additions & 0 deletions forui/lib/src/theme/theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ final class FThemeData with Diagnosticable {
/// The progress styles.
final FProgressStyle progressStyle;

/// The resizable style.
final FResizableStyle resizableStyle;

/// The tabs styles.
final FTabsStyle tabsStyle;

Expand Down Expand Up @@ -92,6 +95,7 @@ final class FThemeData with Diagnosticable {
required this.dialogStyle,
required this.headerStyle,
required this.progressStyle,
required this.resizableStyle,
required this.tabsStyle,
required this.textFieldStyle,
required this.scaffoldStyle,
Expand Down Expand Up @@ -124,6 +128,7 @@ final class FThemeData with Diagnosticable {
dialogStyle: FDialogStyle.inherit(colorScheme: colorScheme, typography: typography, style: style),
headerStyle: FHeaderStyles.inherit(colorScheme: colorScheme, typography: typography, style: style),
progressStyle: FProgressStyle.inherit(colorScheme: colorScheme, style: style),
resizableStyle: FResizableStyle.inherit(colorScheme: colorScheme),
tabsStyle: FTabsStyle.inherit(colorScheme: colorScheme, typography: typography, style: style),
textFieldStyle: FTextFieldStyle.inherit(colorScheme: colorScheme, typography: typography, style: style),
scaffoldStyle: FScaffoldStyle.inherit(colorScheme: colorScheme, style: style),
Expand Down Expand Up @@ -164,6 +169,7 @@ final class FThemeData with Diagnosticable {
FDialogStyle? dialogStyle,
FHeaderStyles? headerStyle,
FProgressStyle? progressStyle,
FResizableStyle? resizableStyle,
FTabsStyle? tabsStyle,
FTextFieldStyle? textFieldStyle,
FScaffoldStyle? scaffoldStyle,
Expand All @@ -185,6 +191,7 @@ final class FThemeData with Diagnosticable {
dialogStyle: dialogStyle ?? this.dialogStyle,
headerStyle: headerStyle ?? this.headerStyle,
progressStyle: progressStyle ?? this.progressStyle,
resizableStyle: resizableStyle ?? this.resizableStyle,
tabsStyle: tabsStyle ?? this.tabsStyle,
textFieldStyle: textFieldStyle ?? this.textFieldStyle,
scaffoldStyle: scaffoldStyle ?? this.scaffoldStyle,
Expand All @@ -210,6 +217,7 @@ final class FThemeData with Diagnosticable {
..add(DiagnosticsProperty('dialogStyle', dialogStyle, level: DiagnosticLevel.debug))
..add(DiagnosticsProperty('headerStyle', headerStyle, level: DiagnosticLevel.debug))
..add(DiagnosticsProperty('progressStyle', progressStyle))
..add(DiagnosticsProperty('resizableStyle', resizableStyle))
..add(DiagnosticsProperty('tabsStyle', tabsStyle, level: DiagnosticLevel.debug))
..add(DiagnosticsProperty('textFieldStyle', textFieldStyle, level: DiagnosticLevel.debug))
..add(DiagnosticsProperty('scaffoldStyle', scaffoldStyle, level: DiagnosticLevel.debug))
Expand All @@ -236,6 +244,7 @@ final class FThemeData with Diagnosticable {
dialogStyle == other.dialogStyle &&
headerStyle == other.headerStyle &&
progressStyle == other.progressStyle &&
resizableStyle == other.resizableStyle &&
tabsStyle == other.tabsStyle &&
textFieldStyle == other.textFieldStyle &&
scaffoldStyle == other.scaffoldStyle &&
Expand All @@ -258,6 +267,7 @@ final class FThemeData with Diagnosticable {
dialogStyle.hashCode ^
headerStyle.hashCode ^
progressStyle.hashCode ^
resizableStyle.hashCode ^
tabsStyle.hashCode ^
textFieldStyle.hashCode ^
scaffoldStyle.hashCode ^
Expand Down
Loading