Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1e97cd4
Initial package import, unchanged
stuartmorgan-g Sep 13, 2021
24d59c5
Initial example import; just paths adjusted
stuartmorgan-g Sep 13, 2021
33a2bd3
Recreate example macOS directory
stuartmorgan-g Sep 13, 2021
3db8122
Metadata and copyright format fixes
stuartmorgan-g Sep 13, 2021
58fda87
Rename plugin class, initial unit test setup
stuartmorgan-g Sep 13, 2021
7ec8b83
Build out test coverage
stuartmorgan-g Sep 23, 2021
662da25
Fix podspec
stuartmorgan-g Sep 24, 2021
5467ffc
Translate to Swift
stuartmorgan-g Sep 24, 2021
9db6ce7
CHANGELOG
stuartmorgan-g Sep 24, 2021
c055be9
Exclude from integration tests
stuartmorgan-g Sep 24, 2021
4398038
Fix pubspec order
stuartmorgan-g Sep 24, 2021
72e3357
Change homepage to a path that already exists
stuartmorgan-g Sep 24, 2021
a140955
Resync example for changes since forking
stuartmorgan-g Sep 24, 2021
daa11d0
README tweak
stuartmorgan-g Sep 24, 2021
fb64d05
Merge branch 'master' into file-selector-macos
stuartmorgan-g Sep 24, 2021
36118a3
Fix for new analysis
stuartmorgan-g Sep 24, 2021
8812e88
Merge branch 'flutter:master' into file-selector-macos
stuartmorgan Oct 5, 2021
d37ba06
Merge branch 'main' into file-selector-macos
stuartmorgan-g Feb 3, 2022
9e64991
Apply example fixes from Windows review
stuartmorgan-g Feb 3, 2022
0e742ae
Update native test fakes for changes on master
stuartmorgan-g Feb 3, 2022
c7f483a
Add in-package platform channel
stuartmorgan-g Feb 3, 2022
3983750
Rework test fakes so they aren't fragile to engine changes
stuartmorgan-g Feb 3, 2022
44d5470
Merge branch 'flutter:main' into file-selector-macos
stuartmorgan Feb 17, 2022
e822ac7
Remove pointless test group
stuartmorgan-g Mar 2, 2022
a7ed104
Move flattening of allowed types from Swift to Dart
stuartmorgan-g Mar 2, 2022
b850177
Merge branch 'main' into file-selector-macos
stuartmorgan-g Mar 2, 2022
e867e7e
Review fixes
stuartmorgan-g Mar 4, 2022
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
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,4 @@ task:
native_test_script:
- ./script/tool_runner.sh native-test --macos
drive_script:
- ./script/tool_runner.sh drive-examples --macos
- ./script/tool_runner.sh drive-examples --macos --exclude=script/configs/exclude_integration_macos.yaml
5 changes: 5 additions & 0 deletions packages/file_selector/file_selector_macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dart_tool
.packages
.flutter-plugins
.flutter-plugins-dependencies
pubspec.lock
10 changes: 10 additions & 0 deletions packages/file_selector/file_selector_macos/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 6d1c244b79f3a2747281f718297ce248bd5ad099
channel: master

project_type: plugin
6 changes: 6 additions & 0 deletions packages/file_selector/file_selector_macos/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the Flutter project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
26 changes: 26 additions & 0 deletions packages/file_selector/file_selector_macos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## 0.8.2

* Moves source to flutter/plugins.
* Adds native unit tests.
* Converts native implementation to Swift.
* Switches to an internal method channel implementation.

## 0.0.4+1

* Update README

## 0.0.4

* Treat empty filter lists the same as null.

## 0.0.3

* Fix README

## 0.0.2

* Update SDK constraint to signal compatibility with null safety.

## 0.0.1

* Initial macOS implementation of `file_selector`.
25 changes: 25 additions & 0 deletions packages/file_selector/file_selector_macos/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2013 The Flutter Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 changes: 34 additions & 0 deletions packages/file_selector/file_selector_macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# file\_selector\_macos

The macOS implementation of [`file_selector`][1].

## Usage

### Importing the package

This implementation has not yet been endorsed, meaning that you need to
[depend on `file_selector_macos`][2] in addition to
[depending on `file_selector`][3].

Once your pubspec includes the macOS implementation, you can use the
`file_selector` APIs normally. You should not use the `file_selector_macos`
APIs directly.

### Entitlements

You will need to [add an entitlement][4] for either read-only access:
```
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
```
or read/write access:
```
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
```
depending on your use case.

[1]: https://pub.dev/packages/file_selector
[2]: https://pub.dev/packages/file_selector_macos/install
[3]: https://pub.dev/packages/file_selector/install
[4]: https://flutter.dev/desktop#entitlements-and-the-app-sandbox
48 changes: 48 additions & 0 deletions packages/file_selector/file_selector_macos/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Currently only web supported
android/
ios/

# Exceptions to above rules.
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
10 changes: 10 additions & 0 deletions packages/file_selector/file_selector_macos/example/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 7736f3bc90270dcb0480db2ccffbf1d13c28db85
channel: dev

project_type: app
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# `file_selector_macos` example

Demonstrates macOS implementation of the
[`file_selector` plugin](https://pub.dev/packages/file_selector).
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
import 'package:flutter/material.dart';

/// Screen that allows the user to select a directory using `getDirectoryPath`,
/// then displays the selected directory in a dialog.
class GetDirectoryPage extends StatelessWidget {
Future<void> _getDirectoryPath(BuildContext context) async {
const String confirmButtonText = 'Choose';
final String? directoryPath =
await FileSelectorPlatform.instance.getDirectoryPath(
confirmButtonText: confirmButtonText,
);
if (directoryPath == null) {
// Operation was canceled by the user.
return;
}
await showDialog<void>(
context: context,
builder: (BuildContext context) => TextDisplay(directoryPath),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Open a text file'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.blue,
onPrimary: Colors.white,
),
child: const Text('Press to ask user to choose a directory'),
onPressed: () => _getDirectoryPath(context),
),
],
),
),
);
}
}

/// Widget that displays a text file in a dialog.
class TextDisplay extends StatelessWidget {
/// Creates a `TextDisplay`.
const TextDisplay(this.directoryPath);

/// The path selected in the dialog.
final String directoryPath;

@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Selected Directory'),
content: Scrollbar(
child: SingleChildScrollView(
child: Text(directoryPath),
),
),
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () => Navigator.pop(context),
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

/// Home Page of the application.
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ButtonStyle style = ElevatedButton.styleFrom(
primary: Colors.blue,
onPrimary: Colors.white,
);
return Scaffold(
appBar: AppBar(
title: const Text('File Selector Demo Home Page'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
style: style,
child: const Text('Open a text file'),
onPressed: () => Navigator.pushNamed(context, '/open/text'),
),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: const Text('Open an image'),
onPressed: () => Navigator.pushNamed(context, '/open/image'),
),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: const Text('Open multiple images'),
onPressed: () => Navigator.pushNamed(context, '/open/images'),
),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: const Text('Save a file'),
onPressed: () => Navigator.pushNamed(context, '/save/text'),
),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: const Text('Open a get directory dialog'),
onPressed: () => Navigator.pushNamed(context, '/directory'),
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:example/get_directory_page.dart';
import 'package:example/home_page.dart';
import 'package:example/open_image_page.dart';
import 'package:example/open_multiple_images_page.dart';
import 'package:example/open_text_page.dart';
import 'package:example/save_text_page.dart';
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

/// MyApp is the Main Application.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'File Selector Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: HomePage(),
routes: <String, WidgetBuilder>{
'/open/image': (BuildContext context) => OpenImagePage(),
'/open/images': (BuildContext context) => OpenMultipleImagesPage(),
'/open/text': (BuildContext context) => OpenTextPage(),
'/save/text': (BuildContext context) => SaveTextPage(),
'/directory': (BuildContext context) => GetDirectoryPage(),
},
);
}
}
Loading