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

Add support for Cupertino widgets and all the adaptive widgets #946

Merged
merged 10 commits into from
Oct 21, 2023
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* fix: `ProgressRing` and `ProgressBar` now fit correctly the parent bounds ([#942](https://github.com/bdlukaa/fluent_ui/issues/942))
* fix: `TabView` buttons was only rendered on hover. Now the buttons (add and scroll buttons) are always rendered.
* fix: `ComboboxItem` correctly apply foreground color. Added `ComboboxItem.enabled` ([#949](https://github.com/bdlukaa/fluent_ui/issues/949))
* Add a support for Cupertino Loclizations from GlobalCupertinoLocalizations, this can help fix some errors when using offical adaptive widgets and other cupertino widgets
* Upgrade the `scroll_pos` dependecy to the latest version which is 0.5.0

## 4.7.6

Expand Down
42 changes: 32 additions & 10 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/cupertino.dart' show CupertinoScrollbar;
import 'package:flutter/material.dart' as m;
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart'
show
GlobalMaterialLocalizations,
GlobalWidgetsLocalizations,
GlobalCupertinoLocalizations;

/// An application that uses fluent design.
///
Expand Down Expand Up @@ -379,17 +384,27 @@ class _FluentAppState extends State<FluentApp> {
_heroController = HeroController();
}

// Combine the Localizations for Material with the ones contributed
// by the localizationsDelegates parameter, if any. Only the first delegate
// of a particular LocalizationsDelegate.type is loaded so the
// localizationsDelegate parameter can be used to override
// _FluentLocalizationsDelegate.
/// Combine the Localizations for Material, Cupertino with the ones contributed
/// by the localizationsDelegates parameter, if any. Only the first delegate
/// of a particular LocalizationsDelegate.type is loaded so the
/// localizationsDelegate parameter can be used to override
/// _FluentLocalizationsDelegate.
///
/// The default value for the localizationsDelegates
/// ```
/// FluentLocalizations.delegate,
/// DefaultMaterialLocalizations.delegate,
/// DefaultCupertinoLocalizations.delegate,
/// DefaultWidgetsLocalizations.delegate
/// ```
Iterable<LocalizationsDelegate<dynamic>> get _localizationsDelegates sync* {
if (widget.localizationsDelegates != null) {
yield* widget.localizationsDelegates!;
final localizationsDelegates = widget.localizationsDelegates;
if (localizationsDelegates != null) {
yield* localizationsDelegates;
}
yield FluentLocalizations.delegate;
yield GlobalMaterialLocalizations.delegate;
yield GlobalCupertinoLocalizations.delegate;
yield GlobalWidgetsLocalizations.delegate;
}

Expand Down Expand Up @@ -558,6 +573,9 @@ class _FluentAppState extends State<FluentApp> {
/// See also:
///
/// * [ScrollBehavior], the default scrolling behavior extended by this class.
/// By default we will use [CupertinoScrollbar] for iOS and macOS platforms
/// for windows and Linux [Scrollbar]
/// for Android and Fuchsia we will return the child
class FluentScrollBehavior extends ScrollBehavior {
/// Creates a FluentScrollBehavior that decorates [Scrollable]s with
/// [Scrollbar]s based on the current platform and provided [ScrollableDetails].
Expand All @@ -572,16 +590,20 @@ class FluentScrollBehavior extends ScrollBehavior {
return child;
case Axis.vertical:
switch (getPlatform(context)) {
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.iOS:
return CupertinoScrollbar(
controller: details.controller,
child: child,
);
case TargetPlatform.linux:
case TargetPlatform.windows:
return Scrollbar(
controller: details.controller,
child: child,
);
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.iOS:
return child;
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies:
scroll_pos: '>=0.5.0 < 1.0.0'

# Used on icon generator
recase: ^4.0.0
recase: ^4.1.0

# Used on NumberBox
math_expressions: ^2.4.0
Expand Down