Skip to content

Commit

Permalink
Fix broken web support, platform theming issues, and typography updat…
Browse files Browse the repository at this point in the history
…es (#460)

* start fixing gallery for web

* additional platform safety, theme, and typographic fixes

* update version
  • Loading branch information
GroovinChip authored Jul 19, 2023
1 parent 64472fe commit 0e8231f
Show file tree
Hide file tree
Showing 16 changed files with 301 additions and 96 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [2.0.0-beta.10]
🛠️ Fixed 🛠️
* Ensure builds targeting web do not utilize any `macos_window_utils` code
* Ensure builds targeting web are themed correctly

🔄 Updated 🔄
* `MacosTypography` white and black are now factory constructors called `darkOpaque()` and `lightOpaque()` to reflect
Apple's naming conventions.
* `PushButton` now uses the correct `body` text style instead of the incorrect `headline`
* `Toolbar` now uses the correct `title3` text style instead of the incorrect `headline`
* `MacosTheme` sets the global typography, per theme, more efficiently

## [2.0.0-beta.9]
* `ResizablePane` can now disallow the usage of its internal scrollbar via the `ReziablePane.noScrollBar` constructor.

Expand Down
73 changes: 37 additions & 36 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:example/pages/buttons_page.dart';
import 'package:example/pages/colors_page.dart';
import 'package:example/pages/dialogs_page.dart';
Expand All @@ -9,9 +11,12 @@ import 'package:example/pages/sliver_toolbar_page.dart';
import 'package:example/pages/tabview_page.dart';
import 'package:example/pages/toolbar_page.dart';
import 'package:example/pages/typography_page.dart';
import 'package:example/platform_menus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

import 'theme.dart';

Expand All @@ -22,7 +27,11 @@ Future<void> _configureMacosWindowUtils() async {
}

Future<void> main() async {
await _configureMacosWindowUtils();
if (!kIsWeb) {
if (Platform.isMacOS) {
await _configureMacosWindowUtils();
}
}

runApp(const MacosUIGalleryApp());
}
Expand Down Expand Up @@ -78,38 +87,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {
@override
Widget build(BuildContext context) {
return PlatformMenuBar(
menus: const [
PlatformMenu(
label: 'macos_ui Widget Gallery',
menus: [
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.about,
),
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.quit,
),
],
),
PlatformMenu(
label: 'View',
menus: [
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.toggleFullScreen,
),
],
),
PlatformMenu(
label: 'Window',
menus: [
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.minimizeWindow,
),
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.zoomWindow,
),
],
),
],
menus: menuBarItems(),
child: MacosWindow(
sidebar: Sidebar(
top: MacosSearchField(
Expand Down Expand Up @@ -184,7 +162,17 @@ class _WidgetGalleryState extends State<WidgetGallery> {
builder: (context, scrollController) {
return SidebarItems(
currentIndex: pageIndex,
onChanged: (i) => setState(() => pageIndex = i),
onChanged: (i) {
if (kIsWeb && i == 10) {
launchUrl(
Uri.parse(
'https://www.figma.com/file/IX6ph2VWrJiRoMTI1Byz0K/Apple-Design-Resources---macOS-(Community)?node-id=0%3A1745&mode=dev',
),
);
} else {
setState(() => pageIndex = i);
}
},
scrollController: scrollController,
itemSize: SidebarItemSize.large,
items: const [
Expand Down Expand Up @@ -281,7 +269,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {
);
},
),
child: IndexedStack(
/*child: IndexedStack(
index: pageIndex,
children: pageBuilders
.asMap()
Expand All @@ -291,7 +279,20 @@ class _WidgetGalleryState extends State<WidgetGallery> {
})
.values
.toList(),
),
),*/
child: [
CupertinoTabView(builder: (_) => const ButtonsPage()),
const IndicatorsPage(),
const FieldsPage(),
const ColorsPage(),
const DialogsPage(),
const ToolbarPage(),
const SliverToolbarPage(isVisible: !kIsWeb),
const TabViewPage(),
const ResizablePanePage(),
const SelectorsPage(),
const TypographyPage(),
][pageIndex],
),
);
}
Expand Down
13 changes: 8 additions & 5 deletions example/lib/pages/selectors_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:example/widgets/widget_text_title1.dart';
import 'package:example/widgets/widget_text_title2.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

Expand Down Expand Up @@ -79,11 +80,13 @@ class _SelectorsPageState extends State<SelectorsPage> {
],
),
const SizedBox(height: 20),
const WidgetTextTitle1(widgetName: 'MacosColorWell'),
Divider(color: MacosTheme.of(context).dividerColor),
MacosColorWell(
onColorSelected: (color) => debugPrint('$color'),
),
if (!kIsWeb) ...[
const WidgetTextTitle1(widgetName: 'MacosColorWell'),
Divider(color: MacosTheme.of(context).dividerColor),
MacosColorWell(
onColorSelected: (color) => debugPrint('$color'),
),
],
],
),
);
Expand Down
52 changes: 52 additions & 0 deletions example/lib/platform_menus.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'package:flutter/foundation.dart' show kIsWeb;
import 'dart:io' as io;

import 'package:flutter/widgets.dart'
show
PlatformMenu,
PlatformMenuItem,
PlatformProvidedMenuItem,
PlatformProvidedMenuItemType;

List<PlatformMenuItem> menuBarItems() {
if (kIsWeb) {
return [];
} else {
if (io.Platform.isMacOS) {
return const [
PlatformMenu(
label: 'macos_ui Widget Gallery',
menus: [
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.about,
),
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.quit,
),
],
),
PlatformMenu(
label: 'View',
menus: [
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.toggleFullScreen,
),
],
),
PlatformMenu(
label: 'Window',
menus: [
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.minimizeWindow,
),
PlatformProvidedMenuItem(
type: PlatformProvidedMenuItemType.zoomWindow,
),
],
),
];
} else {
return [];
}
}
}
2 changes: 2 additions & 0 deletions example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import Foundation
import macos_ui
import macos_window_utils
import path_provider_foundation
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
6 changes: 6 additions & 0 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- url_launcher_macos (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- macos_ui (from `Flutter/ephemeral/.symlinks/plugins/macos_ui/macos`)
- macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)

EXTERNAL SOURCES:
FlutterMacOS:
Expand All @@ -23,12 +26,15 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos
path_provider_foundation:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos

SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
macos_ui: 6229a8922cd97bafb7d9636c8eb8dfb0744183ca
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95

PODFILE CHECKSUM: ff0a9a3ce75ee73f200ca7e2f47745698c917ef9

Expand Down
71 changes: 70 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
google_fonts:
dependency: "direct main"
description:
Expand Down Expand Up @@ -145,7 +150,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-beta.9"
version: "2.0.0-beta.10"
macos_window_utils:
dependency: transitive
description:
Expand Down Expand Up @@ -335,6 +340,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
sha256: "781bd58a1eb16069412365c98597726cd8810ae27435f04b3b4d3a470bacd61e"
url: "https://pub.dev"
source: hosted
version: "6.1.12"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: "15f5acbf0dce90146a0f5a2c4a002b1814a6303c4c5c075aa2623b2d16156f03"
url: "https://pub.dev"
source: hosted
version: "6.0.36"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "207f4ddda99b95b4d4868320a352d374b0b7e05eefad95a4a26f57da413443f5"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "1c4fdc0bfea61a70792ce97157e5cc17260f61abbe4f39354513f39ec6fd73b1"
url: "https://pub.dev"
source: hosted
version: "3.0.6"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: bfdfa402f1f3298637d71ca8ecfe840b4696698213d5346e9d12d4ab647ee2ea
url: "https://pub.dev"
source: hosted
version: "2.1.3"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: cc26720eefe98c1b71d85f9dc7ef0cada5132617046369d9dc296b3ecaa5cbb4
url: "https://pub.dev"
source: hosted
version: "2.0.18"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "7967065dd2b5fccc18c653b97958fdf839c5478c28e767c61ee879f4e7882422"
url: "https://pub.dev"
source: hosted
version: "3.0.7"
vector_math:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
path: ..
provider: ^6.0.5
google_fonts: ^5.1.0
url_launcher: ^6.1.12

dev_dependencies:
flutter_test:
Expand Down
3 changes: 1 addition & 2 deletions lib/src/buttons/push_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ class PushButtonState extends State<PushButton>
? const Color.fromRGBO(255, 255, 255, 0.25)
: const Color.fromRGBO(0, 0, 0, 0.25);

final baseStyle =
theme.typography.headline.copyWith(color: foregroundColor);
final baseStyle = theme.typography.body.copyWith(color: foregroundColor);

return MouseRegion(
cursor: widget.mouseCursor!,
Expand Down
Loading

0 comments on commit 0e8231f

Please sign in to comment.