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 4 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.7.7
- Add a support for Cupertino Loclizations from GlobalCupertinoLocalizations, this can help fix some errors when using offical adaptive widgets and other cupertino widgets
- Now, By default we will use CupertinoScrollbar() widget for iOS and macOS, you can change this in the scrollBehavior to fit your needs if needed.
EchoEllet marked this conversation as resolved.
Show resolved Hide resolved

## [next]

* fix: `ProgressRing` and `ProgressBar` now fit correctly the parent bounds ([#942](https://github.com/bdlukaa/fluent_ui/issues/942))
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
@@ -1,6 +1,6 @@
name: fluent_ui
description: Implements Windows UI in Flutter. Based on the official documentation
version: 4.7.6
version: 4.7.7
EchoEllet marked this conversation as resolved.
Show resolved Hide resolved
homepage: https://bdlukaa.github.io/fluent_ui/#/
repository: https://github.com/bdlukaa/fluent_ui
issue_tracker: https://github.com/bdlukaa/fluent_ui/issues
Expand Down
Loading