Skip to content

Commit

Permalink
fix(web): libadwaita exceptions and platform doesn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Nov 18, 2022
1 parent 4df31be commit 0090294
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.3+1/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.17/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.3+1/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_android-6.0.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"macos_ui","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/macos_ui-1.7.5/","native_build":true,"dependencies":[]},{"name":"package_info_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.3.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-3.0.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_linux-1.0.5/","native_build":false,"dependencies":[]},{"name":"url_launcher_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-3.0.1/","native_build":true,"dependencies":[]}],"windows":[{"name":"package_info_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-2.1.0/","native_build":false,"dependencies":[]},{"name":"url_launcher_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-3.0.1/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.6/","dependencies":[]},{"name":"url_launcher_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.13/","dependencies":[]}]},"dependencyGraph":[{"name":"macos_ui","dependencies":[]},{"name":"package_info_plus","dependencies":["package_info_plus_linux","package_info_plus_macos","package_info_plus_windows","package_info_plus_web"]},{"name":"package_info_plus_linux","dependencies":[]},{"name":"package_info_plus_macos","dependencies":[]},{"name":"package_info_plus_web","dependencies":[]},{"name":"package_info_plus_windows","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2022-11-04 12:48:05.162500","version":"3.3.5"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.3+1/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_ios-6.0.17/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus-1.4.3+1/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_android-6.0.21/","native_build":true,"dependencies":[]}],"macos":[{"name":"macos_ui","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/macos_ui-1.7.5/","native_build":true,"dependencies":[]},{"name":"package_info_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_macos-1.3.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-3.0.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_linux-1.0.5/","native_build":false,"dependencies":[]},{"name":"url_launcher_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-3.0.1/","native_build":true,"dependencies":[]}],"windows":[{"name":"package_info_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_windows-2.1.0/","native_build":false,"dependencies":[]},{"name":"url_launcher_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-3.0.1/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/package_info_plus_web-1.0.6/","dependencies":[]},{"name":"url_launcher_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-2.0.13/","dependencies":[]}]},"dependencyGraph":[{"name":"macos_ui","dependencies":[]},{"name":"package_info_plus","dependencies":["package_info_plus_linux","package_info_plus_macos","package_info_plus_windows","package_info_plus_web"]},{"name":"package_info_plus_linux","dependencies":[]},{"name":"package_info_plus_macos","dependencies":[]},{"name":"package_info_plus_web","dependencies":[]},{"name":"package_info_plus_windows","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2022-11-18 17:11:19.823935","version":"3.3.8"}
3 changes: 1 addition & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'package:example/basic.dart';
import 'package:example/dialog_tabs.dart';
import 'package:example/input.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:fluent_ui/fluent_ui.dart' as FluentUI;

void main() {
platform = TargetPlatform.linux;
platform = TargetPlatform.macOS;
runApp(const MyApp());
}

Expand Down
2 changes: 2 additions & 0 deletions lib/src/platform_app_bar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:fluent_ui/fluent_ui.dart' hide Colors;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:libadwaita/libadwaita.dart';
import 'package:libadwaita_core/libadwaita_core.dart';
Expand Down Expand Up @@ -131,6 +132,7 @@ class PlatformAppBar extends StatelessWidget

@override
Widget linux(BuildContext context) {
if (kIsWeb) return macos(context);
final adwHeaderBar = AdwHeaderBar(
actions: AdwActions(),
title: title != null && titleTextStyle != null
Expand Down
12 changes: 12 additions & 0 deletions lib/src/platform_tab_view.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:libadwaita/libadwaita.dart';
import 'package:libadwaita_core/libadwaita_core.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:platform_ui/platform_ui.dart';
import 'package:fluent_ui/fluent_ui.dart' as FluentUI;
import 'package:collection/collection.dart';
import 'package:platform_ui/src/tools/utils.dart';

class PlatformTab {
final String label;
Expand Down Expand Up @@ -357,6 +359,16 @@ class _PlatformTabViewState extends State<PlatformTabView>

@override
Widget linux(BuildContext context) {
if (kIsWeb) {
return FluentUI.FluentTheme(
data: Utils.brightnessSpecific(
context,
light: FluentUI.ThemeData.light(),
dark: FluentUI.ThemeData.dark(),
),
child: windows(context),
);
}
final tabbar = AdwViewSwitcher(
policy: widget.placement?.linux == PlatformTabbarPlacement.bottom
? ViewSwitcherPolicy.narrow
Expand Down
12 changes: 8 additions & 4 deletions lib/src/tools/platform_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ mixin PlatformMixin<T> {
T linux(BuildContext context);

T getPlatformType(BuildContext context) {
if (kIsWeb) return android(context);
switch (platform ?? defaultTargetPlatform) {
if (!kIsWeb) {
platform ??= defaultTargetPlatform;
}
switch (platform) {
case TargetPlatform.iOS:
return ios(context);
case TargetPlatform.macOS:
Expand All @@ -36,8 +38,10 @@ mixin PlatformBusinessMixin<T> {
T linux();

T getPlatformType() {
if (kIsWeb) return android();
switch (platform ?? defaultTargetPlatform) {
if (!kIsWeb) {
platform ??= defaultTargetPlatform;
}
switch (platform) {
case TargetPlatform.iOS:
return ios();
case TargetPlatform.macOS:
Expand Down

0 comments on commit 0090294

Please sign in to comment.