forked from davidoberger/packages.flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1db583
commit 27bc235
Showing
27 changed files
with
1,284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# 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/ | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
build/ | ||
|
||
# Android related | ||
**/android/**/gradle-wrapper.jar | ||
**/android/.gradle | ||
**/android/captures/ | ||
**/android/gradlew | ||
**/android/gradlew.bat | ||
**/android/local.properties | ||
**/android/**/GeneratedPluginRegistrant.java | ||
|
||
# iOS/XCode related | ||
**/ios/**/*.mode1v3 | ||
**/ios/**/*.mode2v3 | ||
**/ios/**/*.moved-aside | ||
**/ios/**/*.pbxuser | ||
**/ios/**/*.perspectivev3 | ||
**/ios/**/*sync/ | ||
**/ios/**/.sconsign.dblite | ||
**/ios/**/.tags* | ||
**/ios/**/.vagrant/ | ||
**/ios/**/DerivedData/ | ||
**/ios/**/Icon? | ||
**/ios/**/Pods/ | ||
**/ios/**/.symlinks/ | ||
**/ios/**/profile | ||
**/ios/**/xcuserdata | ||
**/ios/.generated/ | ||
**/ios/Flutter/App.framework | ||
**/ios/Flutter/Flutter.framework | ||
**/ios/Flutter/Flutter.podspec | ||
**/ios/Flutter/Generated.xcconfig | ||
**/ios/Flutter/app.flx | ||
**/ios/Flutter/app.zip | ||
**/ios/Flutter/flutter_assets/ | ||
**/ios/Flutter/flutter_export_environment.sh | ||
**/ios/ServiceDefinitions.json | ||
**/ios/Runner/GeneratedPluginRegistrant.* | ||
|
||
# Exceptions to above rules. | ||
!**/ios/**/default.mode1v3 | ||
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 78910062997c3a836feee883712c241a5fd22983 | ||
channel: stable | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
// Используйте IntelliSense, чтобы узнать о возможных атрибутах. | ||
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов. | ||
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "explorer", | ||
"request": "launch", | ||
"type": "dart" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"sqlite" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## [1.0.0] - Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Serge Shkurko | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# explorer | ||
|
||
Universal explorer UI for navigate files, ftp, etc | ||
|
||
Support custom providers and any platforms | ||
|
||
## Getting Started | ||
|
||
In your flutter project add the dependency: | ||
|
||
[](https://pub.dartlang.org/packages/explorer) | ||
|
||
```yaml | ||
dependencies: | ||
flutter_color: any | ||
``` | ||
## Examples | ||
```dart | ||
_controller = ExplorerController( | ||
navigator: IoNavigatorExplorer( | ||
entryPath: _server.serverDirectory, | ||
), | ||
uploadFiles: uploadFiles, | ||
filePressed: (file) { | ||
if (file.size > 200000) { | ||
final snackBar = | ||
SnackBar(content: Text('Can\'t open files with size > 200kb')); | ||
|
||
// Find the Scaffold in the widget tree and use it to show a SnackBar. | ||
ScaffoldMessenger.of(context).showSnackBar(snackBar); | ||
return; | ||
} | ||
if (file.extension.contains(RegExp(r'^(phar|dat)$'))) { | ||
final snackBar = SnackBar( | ||
content: Text('Can\'t open files with extensions: ' + | ||
' phar|dat')); | ||
|
||
// Find the Scaffold in the widget tree and use it to show a SnackBar. | ||
ScaffoldMessenger.of(context).showSnackBar(snackBar); | ||
return; | ||
} | ||
|
||
Navigator.of(context).pushNamed( | ||
EditorScreen.routeName, | ||
arguments: EditorScreenArguments(property: file), | ||
); | ||
}, | ||
) | ||
|
||
Explorer( | ||
controller: _controller, | ||
builder: (_) => [ | ||
ExplorerToolbar(translate: toolbarTranslate), | ||
ExplorerActionView(translate: _actionTranslate), | ||
ExplorerFilesGridView(translate: filesTranslate), | ||
], | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: ../../analysis_options.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
library explorer; | ||
|
||
export 'src/data/models/entry.dart'; | ||
export 'src/explorer.dart'; | ||
export 'src/ui/widgets/action.dart'; | ||
export 'src/ui/widgets/breadcrumbs.dart'; | ||
export 'src/ui/widgets/grid.dart'; | ||
export 'src/ui/widgets/toolbar.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export './explorer.dart'; | ||
export 'src/io/navigator.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
part of '../explorer.dart'; | ||
|
||
class ExplorerController { | ||
ExplorerController({ | ||
@required this.navigator, | ||
this.filePressed, | ||
this.uploadFiles, | ||
}); | ||
|
||
final Future<List<Entry>> Function() uploadFiles; | ||
final NavigatorExplorer navigator; | ||
final void Function(ExplorerFile) filePressed; | ||
|
||
// _ExplorerState _explorerState; | ||
final StreamController<ExplorerState> _files = | ||
StreamController<ExplorerState>.broadcast(); | ||
Stream<ExplorerState> get stream => _files.stream; | ||
|
||
String get entryPath => navigator.entryPath; | ||
String get currentPath => navigator.currentPath; | ||
|
||
final StreamController<ExplorerAction> _actions = | ||
StreamController<ExplorerAction>.broadcast(); | ||
Stream<ExplorerAction> get actionStream => _actions.stream; | ||
|
||
void _attach(_ExplorerState _explorerState) { | ||
assert(_explorerState != null); | ||
// this._explorerState = _explorerState; | ||
navigator.go(navigator.entryPath).then((entries) { | ||
_files.add(ExplorerState( | ||
path: navigator.currentPath, | ||
entries: entries, | ||
)); | ||
}); | ||
_actions.add(ExplorerActionEmpty()); | ||
} | ||
|
||
void _detach() { | ||
// _explorerState = null; | ||
} | ||
|
||
void dispose() { | ||
_files?.close(); | ||
_actions?.close(); | ||
} | ||
|
||
Future<void> uploadLocalFiles() async { | ||
if (uploadFiles == null) { | ||
return; | ||
} | ||
|
||
final entries = await uploadFiles(); | ||
for (final entry in entries) { | ||
await copy(entry, Entry(path: p.join(currentPath, entry.name))); | ||
} | ||
return refresh(); | ||
} | ||
|
||
void copyEntriesRequest(List<Entry> entries) { | ||
_actions.add(ExplorerActionCopy(from: entries)); | ||
} | ||
|
||
void copyEntriesConfirm(List<Entry> entries) async { | ||
for (final entry in entries) { | ||
await copy(entry, Entry(path: p.join(currentPath, entry.name))); | ||
} | ||
_actions.add(ExplorerActionEmpty()); | ||
return refresh(); | ||
} | ||
|
||
void moveEntriesRequest(List<Entry> entries) { | ||
_actions.add(ExplorerActionMove(from: entries)); | ||
} | ||
|
||
void moveEntriesConfirm(List<Entry> entries) async { | ||
for (final entry in entries) { | ||
await copy(entry, Entry(path: p.join(currentPath, entry.name))); | ||
await remove(entry); | ||
} | ||
_actions.add(ExplorerActionEmpty()); | ||
return refresh(); | ||
} | ||
|
||
void cancelAction() { | ||
_actions.add(ExplorerActionEmpty()); | ||
} | ||
|
||
Future<void> copy(Entry from, Entry to) async => navigator.copy(from, to); | ||
|
||
Future<void> goEntry(Entry entry) async { | ||
if (entry is ExplorerDirectory) { | ||
return go(entry.path); | ||
} else { | ||
filePressed(entry); | ||
} | ||
} | ||
|
||
Future<void> go(String path) async { | ||
final entries = await navigator.go(path); | ||
_files.add(ExplorerState( | ||
path: navigator.currentPath, | ||
entries: entries, | ||
)); | ||
} | ||
|
||
Future<void> newDirectory(String name) async { | ||
await navigator.newDirectory(name); | ||
return refresh(); | ||
} | ||
|
||
Future<void> newFile(String name) async { | ||
await navigator.newFile(name); | ||
return refresh(); | ||
} | ||
|
||
Future<void> remove(Entry entry) async { | ||
await navigator.remove(entry); | ||
return refresh(); | ||
} | ||
|
||
Future<void> refresh() => go(currentPath); | ||
|
||
List<PathBreadCrumb> get breadCrumbs { | ||
final names = currentPath.replaceFirst(entryPath, '').split('/') | ||
..removeWhere((element) => element?.isEmpty); | ||
final crumbs = <PathBreadCrumb>[ | ||
PathBreadCrumb(path: entryPath), | ||
]; | ||
|
||
for (final name in names) { | ||
final String path = (crumbs.isNotEmpty) | ||
? p.join(crumbs.last.path, name) | ||
: p.join(entryPath, name); | ||
crumbs.add(PathBreadCrumb( | ||
path: path, | ||
)); | ||
} | ||
|
||
return crumbs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:path/path.dart' as p; | ||
|
||
class PathBreadCrumb { | ||
PathBreadCrumb({this.path}) : name = p.basename(path); | ||
|
||
final String name, path; | ||
|
||
@override | ||
String toString() => '$runtimeType{name: $name, path: $path}'; | ||
} |
Oops, something went wrong.