Skip to content

Commit ab7666b

Browse files
authored
Starter app (#251)
* chore: Update pubspec.yaml files to support Flutter 3 * chore: run dart fix --apply * chore: migrate Scrollbar to Flutter 3 * chore: update flutter_lints & subsequent fixes * feat: add missing functions to MacosColor the Color class has a number of functions that MacosColor had not implemented * chore: use super parameters * chore: update changelog * chore: tweak example app Uses the new PlatformMenuBar. Also update product name. * chore: small changelog tweak * chore: run flutter format . * chore: run dart fix --apply * chore: run flutter format . * chore: remove unused code in example * chore: remove unused import * feat: first pass at starter app brick * chore: improve starter app brick * chore: fix widget test in starter app * feat: conditional prompts & running pub get * chore: finalize brick * chore: run flutter format * chore: exclude starter app from analyzer
1 parent ac6870c commit ab7666b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2212
-0
lines changed

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ linter:
77
analyzer:
88
plugins:
99
- dart_code_metrics
10+
exclude:
11+
- starter_app/**
1012

1113
dart_code_metrics:
1214
metrics:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 1.0.0
2+
3+
* Initial release 🎉
4+
* Generate a new Flutter application that uses `macos_ui`
5+
* Optionally use window translucency
6+
* Optionally hide the native titlebar
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [2021] [Reuben Turner]
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# macosui_starter
2+
3+
![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)
4+
5+
A starter Flutter application for macOS that uses [`macos_ui`](https://pub.dev/packages/macos_ui).
6+
7+
<img src='https://imgur.com/rG4uDKs.png' />
8+
9+
## 🚧 Prerequisites
10+
* Your Flutter version should be at least 3.0
11+
* You should have `mason_cli` installed
12+
13+
## Usage 🚀
14+
```sh
15+
mason make macosui_starter
16+
```
17+
18+
You'll be prompted for the following information:
19+
* The name of your app
20+
* Your app's description
21+
* The name of your organization
22+
* Whether to use window transclucency
23+
* Whether to show or hide the native titlebar
24+
25+
⚠️ **Please note**: if you opt to use window transclucency you will not be asked if you want to show or hide the native
26+
titlebar, as it will be hidden by default.
27+
28+
## Variables ✨
29+
30+
| Variable | Description | Default | Type |
31+
|-------------------|-------------------------------------|---------------------------------------------------------|-----------|
32+
| `app_name` | The name of your app | `macosui_starter` | `string` |
33+
| `app_description` | The description of your application | `A starter Flutter application for macOS with macos_ui` | `string` |
34+
| `org_name` | The name of your organization | `com.example` | `string` |
35+
| `use_translucency`| Whether to use window transclucency | `false` | `boolean` |
36+
37+
## Output 📦
38+
39+
A Flutter application that:
40+
* Targets macOS (support for other platforms can be added manually)
41+
* Has `macos_ui` pre-installed
42+
* Builds basic UI based on the latest version of `macos_ui`
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Web related
36+
lib/generated_plugin_registrant.dart
37+
38+
# Symbolication related
39+
app.*.symbols
40+
41+
# Obfuscation related
42+
app.*.map.json
43+
44+
# Android Studio will place build artifacts here
45+
/android/app/debug
46+
/android/app/profile
47+
/android/app/release
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
8+
channel: stable
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
17+
base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
18+
- platform: macos
19+
create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
20+
base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
21+
22+
# User provided section
23+
24+
# List of Local paths (relative to this file) that should be
25+
# ignored by the migrate tool.
26+
#
27+
# Files that are not part of the templates will be ignored by default.
28+
unmanaged_files:
29+
- 'lib/main.dart'
30+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# {{ app_name }}
2+
3+
A starter Flutter app for macOS with `macos_ui`.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application specifically targeting macOS and uses the `macos_ui` plugin
8+
to achieve UI and UX that match their native AppKit counterparts as closely as possible.
9+
10+
A few resources to get you started if this is your first Flutter project:
11+
12+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
13+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
14+
15+
For help getting started with Flutter development, view the
16+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
17+
samples, guidance on mobile development, and a full API reference.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
- use_super_parameters
28+
29+
# Additional information about this file can be found at
30+
# https://dart.dev/guides/language/analysis-options
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:macos_ui/macos_ui.dart';
4+
5+
void main() {
6+
runApp(const App());
7+
}
8+
9+
class App extends StatelessWidget {
10+
const App({super.key});
11+
12+
// This widget is the root of your application.
13+
@override
14+
Widget build(BuildContext context) {
15+
return MacosApp(
16+
title: '{{ app_name }}',
17+
theme: MacosThemeData.light(),
18+
darkTheme: MacosThemeData.dark(),
19+
themeMode: ThemeMode.system,
20+
home: const MainView(),
21+
);
22+
}
23+
}
24+
25+
class MainView extends StatefulWidget {
26+
const MainView({super.key});
27+
28+
@override
29+
State<MainView> createState() => _MainViewState();
30+
}
31+
32+
class _MainViewState extends State<MainView> {
33+
int _pageIndex = 0;
34+
35+
@override
36+
Widget build(BuildContext context) {
37+
return MacosWindow(
38+
sidebar: Sidebar(
39+
minWidth: 200,
40+
builder: (context, scrollController) => SidebarItems(
41+
currentIndex: _pageIndex,
42+
onChanged: (index) {
43+
setState(() => _pageIndex = index);
44+
},
45+
items: const [
46+
SidebarItem(
47+
leading: MacosIcon(CupertinoIcons.home),
48+
label: Text('Home'),
49+
),
50+
],
51+
),
52+
),
53+
child: IndexedStack(
54+
index: _pageIndex,
55+
children: const [
56+
HomePage(),
57+
],
58+
),
59+
);
60+
}
61+
}
62+
63+
class HomePage extends StatelessWidget {
64+
const HomePage({super.key});
65+
66+
@override
67+
Widget build(BuildContext context) {
68+
return Builder(
69+
builder: (context) {
70+
return MacosScaffold(
71+
toolBar: ToolBar(
72+
title: const Text('Home'),
73+
actions: [
74+
ToolBarIconButton(
75+
label: 'Toggle Sidebar',
76+
icon: const MacosIcon(CupertinoIcons.sidebar_left),
77+
showLabel: false,
78+
tooltipMessage: 'Toggle Sidebar',
79+
onPressed: () {
80+
MacosWindowScope.of(context).toggleSidebar();
81+
},
82+
)
83+
],
84+
),
85+
children: [
86+
ContentArea(
87+
builder: (context, scrollController) {
88+
return const Center(
89+
child: Text('Home'),
90+
);
91+
},
92+
),
93+
],
94+
);
95+
},
96+
);
97+
}
98+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Flutter-related
2+
**/Flutter/ephemeral/
3+
**/Pods/
4+
5+
# Xcode-related
6+
**/dgph
7+
**/xcuserdata/

0 commit comments

Comments
 (0)