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

Full screen opaque toolbar issue (closes #249) #252

Merged
merged 5 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions .github/workflows/dart_code_metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Dart Code Metrics
on: [pull_request, workflow_dispatch]

jobs:
dart-code-metrics:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Install Flutter
uses: subosito/flutter-action@master
with:
channel: stable

- name: Check directory
run: ls
- name: Install Code Metrics
run: flutter pub global activate dart_code_metrics
- name: Run Code Metrics
run: flutter pub global run dart_code_metrics:metrics --reporter=github lib
51 changes: 17 additions & 34 deletions .github/workflows/pana_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Pana Analysis
on: [pull_request, workflow_dispatch]

jobs:
package-analysis:
runs-on: ubuntu-latest
pana-analysis:
runs-on: macos-latest

steps:
- uses: actions/checkout@v2
Expand All @@ -12,40 +12,23 @@ jobs:
with:
channel: stable

#- name: Install dependencies
# run: flutter pub get
- name: Analyze package with Pana
run: |
flutter pub global activate pana 0.21.5

- name: Check directory
run: ls
- name: Install Code Metrics
run: flutter pub global activate dart_code_metrics
- name: Run Code Metrics
run: flutter pub global run dart_code_metrics:metrics --reporter=github lib
REQUIRED_RATIO=1.0
TEMP_FILE=/tmp/pana_results.txt

- uses: axel-op/dart-package-analyzer@v3
# set an id for the current step
id: analysis
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
# Run pana, piping the output to both stderr and into a grep to find the result in the last line.
pana --no-warning | tee /dev/stderr | tail -1 | grep -o -E '[0-9]+' > $TEMP_FILE

# You can then use this id to retrieve the outputs in the next steps.
# The following step shows how to exit the workflow with an error if the total score in percentage is below 50:
- name: Check scores
env:
# NB: "analysis" is the id set above. Replace it with the one you used if different.
TOTAL: ${{ steps.analysis.outputs.total }}
TOTAL_MAX: ${{ steps.analysis.outputs.total_max }}
run: |
PERCENTAGE=$(( $TOTAL * 100 / $TOTAL_MAX ))
if (( $PERCENTAGE < 80 ))
then
echo Score too low!
# Extract score and calculate ratio.
SCORE=$(cat $TEMP_FILE | head -1)
TOTAL=$(cat $TEMP_FILE | tail -1)
RATIO=$(echo "scale=2; $SCORE / $TOTAL" | bc -l)
MEETS_REQUIRED_RATIO=$(echo "$RATIO >= $REQUIRED_RATIO" | bc -l)

if [[ "$MEETS_REQUIRED_RATIO" != "1" ]]; then
echo "Score of $SCORE out of $TOTAL is a ratio of $RATIO, which is not sufficient to meet the required ratio of $REQUIRED_RATIO"
exit 1
fi

# This step is useful for PR's coming from forks. It takes the raw JSON and formats a report from it.
- name: Format scores json
env:
JSON_OUTPUT: ${{ steps.analysis.outputs.json_output }}
run: |
TOTAL_SCORE=$(jq -r '.scores.grantedPoints' <<< "$JSON_OUTPUT")
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [1.4.1]
* Fixes an issue where if the app was displayed in full screen mode, an opaque empty toolbar would appear at the top [#249](https://github.com/GroovinChip/macos_ui/issues/249)
GroovinChip marked this conversation as resolved.
Show resolved Hide resolved

## [1.4.0]
* Migration to Flutter 3.0
* Minimum dart sdk version is now 2.17.0
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ class BlurryContainerViewController: NSViewController {
}
}

class MainFlutterWindow: NSWindow {
class MainFlutterWindow: NSWindow, NSWindowDelegate {
override func awakeFromNib() {
delegate = self
let blurryContainerViewController = BlurryContainerViewController()
let windowFrame = self.frame
self.contentViewController = blurryContainerViewController
Expand Down Expand Up @@ -218,9 +219,16 @@ class MainFlutterWindow: NSWindow {
}

func window(_ window: NSWindow, willUseFullScreenPresentationOptions proposedOptions: NSApplication.PresentationOptions = []) -> NSApplication.PresentationOptions {
// Hides the toolbar when in fullscreen mode
return [.autoHideToolbar, .autoHideMenuBar, .fullScreen]
}

func windowWillEnterFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = false
}

func windowDidExitFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = true
}
}

```
Expand Down
14 changes: 12 additions & 2 deletions example/macos/Runner/MainFlutterWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class BlurryContainerViewController: NSViewController {
}
}

class MainFlutterWindow: NSWindow {
class MainFlutterWindow: NSWindow, NSWindowDelegate {
override func awakeFromNib() {
delegate = self
let blurryContainerViewController = BlurryContainerViewController()
let windowFrame = self.frame
self.contentViewController = blurryContainerViewController
Expand Down Expand Up @@ -64,8 +65,17 @@ class MainFlutterWindow: NSWindow {
super.awakeFromNib()
}

// Hides the toolbar when in fullscreen mode
func window(_ window: NSWindow, willUseFullScreenPresentationOptions proposedOptions: NSApplication.PresentationOptions = []) -> NSApplication.PresentationOptions {
// Hides the toolbar when in fullscreen mode

return [.autoHideToolbar, .autoHideMenuBar, .fullScreen]
}

func windowWillEnterFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = false
}

func windowDidExitFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = true
}
}
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.0"
version: "1.4.1"
matcher:
dependency: transitive
description:
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: macos_ui
description: Flutter widgets and themes implementing the current macOS design language.
version: 1.4.0
version: 1.4.1
homepage: "https://github.com/GroovinChip/macos_ui"

environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class BlurryContainerViewController: NSViewController {
}
}

class MainFlutterWindow: NSWindow {
class MainFlutterWindow: NSWindow, NSWindowDelegate {
override func awakeFromNib() {
delegate = self
let blurryContainerViewController = BlurryContainerViewController()
let windowFrame = self.frame
self.contentViewController = blurryContainerViewController
Expand Down Expand Up @@ -69,6 +70,14 @@ class MainFlutterWindow: NSWindow {
// Hides the toolbar when in fullscreen mode
return [.autoHideToolbar, .autoHideMenuBar, .fullScreen]
}

func windowWillEnterFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = false
}

func windowDidExitFullScreen(_ notification: Notification) {
self.toolbar?.isVisible = true
}
}
{{/use_translucency}}{{^use_translucency}}
class MainFlutterWindow: NSWindow {
Expand Down