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

Layout refactor #153

Merged
merged 34 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2de15a7
Create window.dart
lesliearkorful Aug 6, 2021
7648073
make TitleBar a widget
lesliearkorful Aug 6, 2021
5f1e07b
refactor Scaffold
lesliearkorful Aug 6, 2021
d202f68
Delete resizable_pane_notifier.dart
lesliearkorful Aug 6, 2021
b5df0a9
Update window.dart
lesliearkorful Aug 6, 2021
9bc2638
refactor ResizablePane
lesliearkorful Aug 6, 2021
bcdd72c
Update content_area.dart
lesliearkorful Aug 6, 2021
749bcb7
Update macos_ui.dart
lesliearkorful Aug 6, 2021
ee9fdbc
update example
lesliearkorful Aug 6, 2021
4d116c2
fix imports
lesliearkorful Aug 6, 2021
5b9ad53
Update CHANGELOG.md
lesliearkorful Aug 6, 2021
7b03f39
window: use sidebar topOffset
lesliearkorful Aug 6, 2021
38caa98
sidebar: add topOffset
lesliearkorful Aug 6, 2021
db8a35b
Update README.md
lesliearkorful Aug 7, 2021
78d289a
Update pubspec.yaml
lesliearkorful Aug 7, 2021
499db48
Update pubspec.lock
lesliearkorful Aug 7, 2021
f0711b3
[window] add slide transition to sidebar toggle
lesliearkorful Aug 7, 2021
8cab6de
update examples
lesliearkorful Aug 7, 2021
ff94c84
[titlebar] add customization properties
lesliearkorful Aug 7, 2021
1f85692
fix buttons example
lesliearkorful Aug 7, 2021
a2656b5
[titlebar] use defaultTargetPlatform and remove dart:io
lesliearkorful Aug 7, 2021
472ab9f
[titlebar] show window controls safe area only on macOS
lesliearkorful Aug 7, 2021
a4eab21
add swift code block to README
lesliearkorful Aug 8, 2021
7d1df78
Update MainFlutterWindow.swift
lesliearkorful Aug 9, 2021
f2674dd
change scaffoldBreakpoint to windowBreakpoint on ResizablePane and Si…
lesliearkorful Aug 9, 2021
c33f56a
[titlebar] adjust for no MacosWindowScope
lesliearkorful Aug 9, 2021
27c1765
[window] refactor out unnecessary code
lesliearkorful Aug 9, 2021
a9c40d9
[scaffold] update assertion messages
lesliearkorful Aug 9, 2021
34b12c3
[window] show content in a ClipRect
lesliearkorful Aug 9, 2021
9e7fd4d
Update README.md
lesliearkorful Aug 9, 2021
8e6c813
update example
lesliearkorful Aug 9, 2021
9e834fc
update readme screenshots
lesliearkorful Aug 9, 2021
9e0e931
docs: add a class level doc for sidebar.dart
GroovinChip Aug 12, 2021
c72e1d5
docs: update docs for sidebar.dart
GroovinChip Aug 12, 2021
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 @@
## [0.7.0]
* Adds: `MacosWindow`
* Improved `MacosScaffold`

## [0.6.2]
* Chore: Remove box shadows from `MacosIconButton`

Expand Down
64 changes: 56 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Flutter widgets and themes implementing the current macOS design language.
- [Contributing](#contributing)
- [Resources](#resources)
- [Layout](#layout)
- [MacosWindow](#macoswindow)
- [MacosScaffold](#macosscaffold)
- [Buttons](#buttons)
- [MacosCheckbox](#macoscheckbox)
Expand Down Expand Up @@ -43,20 +44,67 @@ macOS welcomes contributions. Please see CONTRIBUTING.md for more information.

# Layout

## MacosWindow

`MacosWindow` is the basic frame for the macOS layout.

It has a `Sidebar` on the left and the rest of the window is typically filled out
with a `MacosScaffold`. A scope for the `MacosWindow` is provided by `MacosWindowScope`.
The sidebar can be toggled with `MacosWindowScope.of(context).toggleSidebar()`.

<img src="https://imgur.com/LtdfKvv.png" width="75%">


## MacosScaffold

`MacosScaffold` provides a basic structure for laying out widgets in a way you would expect on macOS.
You must specify a `body` as the main content area, and you can optionally provide a `sidebar`
that will show to the left of `body`. The `sidebar` can be resized by grabbing the split and
dragging left or right. See the documentation for all customization options.
The `MacosScaffold` is what you would call a "page".

The scaffold has a `TitleBar` property and the `children` property which accepts a `ContentArea` widget and multiple `ResizablePane` widgets. To catch navigation or routes below the scaffold, consider wrapping the `MacosScaffold` in a [`CupertinoTabView`](https://api.flutter.dev/flutter/cupertino/CupertinoTabView-class.html). By doing so, navigation inside the `MacosScaffold` will be displayed inside the `MacosScaffold` area instead of covering the entire window. To push a route outside a `MacosScaffold` wrapped in a [`CupertinoTabView`](https://api.flutter.dev/flutter/cupertino/CupertinoTabView-class.html), use the root navigator `Navigator.of(context, rootNavigator: true)`

See the documentation for customizations.

<img src="https://imgur.com/waUgeWY.png" width="75%"/>

<img src="https://imgur.com/DihgZmC.png" width="75%"/>

<img src="https://imgur.com/RXhTJj4.jpg" width="75%"/>
<img src="https://imgur.com/mabmh61.png" width="75%"/>

<img src="https://imgur.com/GzKJsbn.png" width="75%"/>
## Modern window look

<img src="https://imgur.com/owpkOPC.png" width="75%"/>
A new look for macOS apps was introduced in Big Sur (macOS 11). To match that look in your Flutter app, like our screenshots, your `macos/Runner/MainFlutterWindow.swift` file should look like this.

<img src="https://imgur.com/f9ZFiLv.png" width="75%"/>
```swift
import Cocoa
import FlutterMacOS

class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
let flutterViewController = FlutterViewController.init()
let windowFrame = self.frame
self.contentViewController = flutterViewController
self.setFrame(windowFrame, display: true)

if #available(macOS 10.13, *) {
let customToolbar = NSToolbar()
customToolbar.showsBaselineSeparator = false
self.toolbar = customToolbar
}
self.titleVisibility = .hidden
self.titlebarAppearsTransparent = true
if #available(macOS 11.0, *) {
self.toolbarStyle = .unified
}

self.isMovableByWindowBackground = true
self.styleMask.insert(NSWindow.StyleMask.fullSizeContentView)

RegisterGeneratedPlugins(registry: flutterViewController)

super.awakeFromNib()
}
}

```

# Buttons

Expand Down
46 changes: 11 additions & 35 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:example/pages/colors_page.dart';
import 'package:example/pages/dialogs_page.dart';
import 'package:example/pages/fields.dart';
import 'package:example/pages/indicators.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:macos_ui/macos_ui.dart';
Expand All @@ -28,10 +29,7 @@ class MyApp extends StatelessWidget {
darkTheme: MacosThemeData.dark(),
themeMode: appTheme.mode,
debugShowCheckedModeBanner: false,
builder: (context, child) {
return Demo();
},
//home: Demo(),
home: Demo(),
);
},
);
Expand All @@ -51,12 +49,14 @@ class _DemoState extends State<Demo> {
int pageIndex = 0;

final List<Widget> pages = [
ButtonsPage(),
CupertinoTabView(
builder: (_) => ButtonsPage(),
),
IndicatorsPage(),
FieldsPage(),
ColorsPage(),
Text('Disclosure item 2'),
Text('Disclosure item 3'),
Center(child: Text('Disclosure item 2')),
Center(child: Text('Disclosure item 3')),
DialogsPage(),
];

Expand All @@ -68,10 +68,10 @@ class _DemoState extends State<Demo> {

@override
Widget build(BuildContext context) {
return MacosScaffold(
titleBar: TitleBar(
size: TitleBarSize.small,
child: Text('macos_ui Widget Gallery'),
return MacosWindow(
child: IndexedStack(
index: pageIndex,
children: pages,
),
sidebar: Sidebar(
minWidth: 200,
Expand Down Expand Up @@ -129,30 +129,6 @@ class _DemoState extends State<Demo> {
);
},
),
children: <Widget>[
ContentArea(
builder: (context, scrollController) {
return SingleChildScrollView(
controller: scrollController,
padding: EdgeInsets.all(20),
child: IndexedStack(
alignment: Alignment.topCenter,
index: pageIndex,
children: pages,
),
);
},
),
// ResizablePane(
// minWidth: 180,
// startWidth: 200,
// scaffoldBreakpoint: 500,
// resizableSide: ResizableSide.left,
// builder: (_, __) {
// return Center(child: Text('Resizable Pane'));
// },
// ),
],
);
}
}
Loading