├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── config.yml
│ └── feature_request.md
├── README.md
└── pull_request_template.md
├── .gitignore
├── .metadata
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── files
│ │ │ │ └── MainActivity.kt
│ │ └── res
│ │ │ ├── drawable-v21
│ │ │ └── launch_background.xml
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-night
│ │ │ └── styles.xml
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── dahliaOS
├── AppRun
├── appManifest.json
├── files.desktop
└── files.png
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── WorkspaceSettings.xcsettings
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-App-1024x1024@1x.png
│ │ ├── Icon-App-20x20@1x.png
│ │ ├── Icon-App-20x20@2x.png
│ │ ├── Icon-App-20x20@3x.png
│ │ ├── Icon-App-29x29@1x.png
│ │ ├── Icon-App-29x29@2x.png
│ │ ├── Icon-App-29x29@3x.png
│ │ ├── Icon-App-40x40@1x.png
│ │ ├── Icon-App-40x40@2x.png
│ │ ├── Icon-App-40x40@3x.png
│ │ ├── Icon-App-60x60@2x.png
│ │ ├── Icon-App-60x60@3x.png
│ │ ├── Icon-App-76x76@1x.png
│ │ ├── Icon-App-76x76@2x.png
│ │ └── Icon-App-83.5x83.5@2x.png
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LaunchImage@3x.png
│ │ └── README.md
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ └── Runner-Bridging-Header.h
├── lib
├── backend
│ ├── database
│ │ ├── helper.dart
│ │ ├── model.dart
│ │ └── model.g.dart
│ ├── entity_info.dart
│ ├── fetch.dart
│ ├── folder_provider.dart
│ ├── path_parts.dart
│ ├── providers.dart
│ ├── stat_cache_proxy.dart
│ ├── utils.dart
│ └── workspace.dart
├── main.dart
└── widgets
│ ├── breadcrumbs_bar.dart
│ ├── context_menu.dart
│ ├── double_scrollbars.dart
│ ├── entity_context_menu.dart
│ ├── folder_dialog.dart
│ ├── grid.dart
│ ├── side_pane.dart
│ ├── tab_strip.dart
│ ├── table.dart
│ ├── timed_inkwell.dart
│ └── workspace.dart
├── linux
├── .gitignore
├── CMakeLists.txt
├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
├── main.cc
├── my_application.cc
└── my_application.h
├── pubspec.lock
├── pubspec.yaml
├── web
├── favicon.png
├── icons
│ ├── Icon-192.png
│ └── Icon-512.png
├── index.html
└── manifest.json
└── windows
├── .gitignore
├── CMakeLists.txt
├── flutter
├── CMakeLists.txt
├── generated_plugin_registrant.cc
├── generated_plugin_registrant.h
└── generated_plugins.cmake
├── libs
└── libisar.dll
└── runner
├── CMakeLists.txt
├── Runner.rc
├── flutter_window.cpp
├── flutter_window.h
├── main.cpp
├── resource.h
├── resources
└── app_icon.ico
├── runner.exe.manifest
├── utils.cpp
├── utils.h
├── win32_window.cpp
└── win32_window.h
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve the File Manager
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **What kind of a bug is it?**
14 | Describe what kind of a bug it is. [e.g. Typo, visual, application bug, OS bug]
15 |
16 | **To Reproduce**
17 | Steps to reproduce the behavior:
18 | 1. Go to '...'
19 | 2. Click on '....'
20 | 3. Scroll down to '....'
21 | 4. See error
22 |
23 | **Expected behavior**
24 | A clear and concise description of what you expected to happen.
25 |
26 | **Screenshots**
27 | If applicable, add screenshots to help explain your problem.
28 |
29 | **Desktop (please complete the following information):**
30 | - OS: [e.g. dahliaOS Linux, dahliaOS Zircon]
31 | - Device: [e.g. MacbookPro9,1, QEMU]
32 |
33 | **Smartphone (please complete the following information):**
34 | - Device: [e.g. iPhone6]
35 | - OS: [e.g. Android, dahliaOS Zircon, dahliaOS Linux]
36 | - Execution Method: [e.g. ADB, Zircon tool]
37 |
38 | **dahliaOS build version**
39 | Write what version of dahliaOS you were using.
40 |
41 | **Additional context**
42 | Add any other context about the problem here.
43 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Help
4 | url: https://dahliaos.io/discord
5 | about: 'If you have a question or need help, join our Discord!'
6 | - name: Documentation issue
7 | url: https://github.com/dahliaos/documentation
8 | about: 'For documentation issues, suggest changes on our documentation repository.'
9 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for the File Manager
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **For which platform is this feature request?**
20 | - Platform: [Linux, Zircon or Mobile]
21 |
22 | **Do you have an idea of how we would add it?**
23 | If you know how we would approach adding this feature, tell us how.
24 |
25 | **Why should we add it?**
26 | Explain to use how our project can benefit of your feature request.
27 |
28 | **Additional context**
29 | Add any other context or screenshots about the feature request here.
30 |
--------------------------------------------------------------------------------
/.github/README.md:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
10 | Website •
11 | Discord •
12 | Releases •
13 | Donate •
14 | Documentation
15 |
16 | # File manager
17 | 
18 | 
19 |
20 | - **File manager** for dahliaOS
21 | - **Written** in Dart/Flutter
22 |
23 | ## Development
24 |
25 | To develop and locally test the application:
26 |
27 | ### Step 1. Install development tools
28 |
29 | 1. Install [Flutter](https://docs.flutter.dev/get-started/install)
30 | 2. Install an IDE of your choice (we recommend [VSCode](https://code.visualstudio.com/))
31 | * We also recommend installing Dart and Flutter extensions if you're opting in for VSCode.
32 | For other IDEs, please inform yourself.
33 |
34 | ### Step 2. Install dependencies
35 |
36 | Install pub dependencies required to run the application by running:
37 |
38 | ```dart
39 | flutter pub get
40 | ```
41 |
42 | ### Step 3. Run the application
43 |
44 | Run the application in an enviroment of your choice by running:
45 |
46 | ```dart
47 | flutter run
48 | ```
49 |
50 | Flutter has hot reloading so no need to restart the instance when it's running!
51 |
52 | ## Contribute
53 |
54 | If you're wondering how to contribute to the project, please refer to [CONTRIBUTING.md](CONTRIBUTING.md)
55 |
56 | ## License
57 |
58 |
59 |
60 |
61 |
62 |
63 | Copyright @ 2019-2022 - The dahliaOS Authors - contact@dahliaos.io
64 |
65 | This project is licensed under the [Apache 2.0 license](/LICENSE)
66 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # Pull request template
2 |
3 | * Please make sure you read and fill this template out entirely
4 | * PRs that don't have the template filled out will be ignored
5 |
6 | ## Description
7 |
8 | - Please include a summary of the change and which issue is fixed
9 | - Please also include relevant motivation and context (Why is this change required? What problem does it solve?)
10 | - List any dependencies that are required for this change
11 | - If it fixes an open issue, plase link to the issue here
12 |
13 | Fixes #(issue)
14 |
15 | ## Screenshots (if appropriate):
16 |
17 | ## Type of change
18 |
19 | Please tick the relevant option by putting an X inside the bracket
20 |
21 | - [ ] Bug fix (non-breaking change which fixes an issue)
22 | - [ ] New feature (non-breaking change which adds functionality)
23 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
24 | - [ ] This change requires a documentation update
25 |
26 | ## Checklist:
27 |
28 | - [ ] My code follows the guidelines of this project
29 | - [ ] I have performed a self-review of my own code
30 | - [ ] I have commented my code, particularly in hard-to-understand areas
31 | - [ ] I have made corresponding changes to the documentation
32 | - [ ] My changes generate no new warnings
33 | - [ ] All current GitHub actions pass
34 | - [ ] Any dependent changes have been merged and published in downstream modules
35 | - [ ] I have checked my code and corrected any misspellings
36 | - [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Android Studio will place build artifacts here
44 | /android/app/debug
45 | /android/app/profile
46 | /android/app/release
47 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
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 and should not be manually edited.
5 |
6 | version:
7 | revision: 45508985b1355a6a8a045024ca0d94e20cd4ac20
8 | channel: master
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # dahliaOS Code of Conduct
2 |
3 | The dahliaOS team is committed to preserving and fostering a
4 | diverse, welcoming community. Below is our community code of conduct, which
5 | applies to our repos and organizations, issue trackers, Discord servers,
6 | blog content, and any other dahliaOS-supported communication group, as
7 | well as any private communication initiated in the context of these
8 | spaces. This code of conduct must be followed by everyone contributing to
9 | the dahliaOS project, regardless of affiliation or position.
10 |
11 | Simply put, community discussions should be
12 |
13 | * respectful and kind;
14 | * about software;
15 | * about features and code, not the individuals involved.
16 |
17 | ## Be respectful and constructive.
18 |
19 | Treat everyone with respect. Build on each other's ideas. Each of us has the
20 | right to enjoy our experience and participate without fear of harassment,
21 | discrimination, or condescension, whether blatant or subtle. Remember that
22 | dahliaOS is a geographically distributed team and that you may not be
23 | communicating with someone in their primary language. We all get frustrated
24 | when working on hard problems, but we cannot allow that frustration to turn
25 | into personal attacks.
26 |
27 | ## Speak up if you see or hear something.
28 |
29 | You are empowered to politely engage when you feel that you or others are
30 | disrespected. The person making you feel uncomfortable may not be aware of what
31 | they are doing - politely bringing their behavior to their attention is
32 | encouraged.
33 |
34 | If you are uncomfortable speaking up, or feel that your concerns are not being
35 | duly considered, you can email the Project Integrity team at integrity@dahliaos.io to request involvement from a moderator. All
36 | concerns shared with community managers will be kept confidential, but you may
37 | also submit an anonymous report [here](dahlia-os.github.io/anon).
38 | Please note that without a way to contact you, an anonymous report may be
39 | difficult to act on. You may also create a throwaway account to report. In
40 | cases where a public response is deemed necessary, the identities of victims
41 | and reporters will remain confidential unless those individuals instruct us
42 | otherwise.
43 |
44 | While all reports will be taken seriously, the Project Integrity Team may
45 | not act on complaints that they feel are not violations of this code of
46 | conduct.
47 |
48 | ## We will not tolerate harassment of any kind, including but not limited to:
49 |
50 | * Harassing comments
51 | * Intimidation
52 | * Arguing over subjective preference, e.g. text editors, nationality, religion, etc.
53 | * Encouraging a person to engage in self-harm.
54 | * Sustained disruption or derailing of threads, channels, lists, etc.
55 | * Offensive or violent comments, jokes or otherwise
56 | * Inappropriate sexual content
57 | * Unwelcome sexual or otherwise aggressive attention
58 | * Continued one-on-one communication after requests to cease
59 | * Distribution or threat of distribution of people's personally identifying
60 | information, AKA “doxing”
61 |
62 | ## Consequences for failing to comply with this policy
63 |
64 | Consequences for failing to comply with this policy may include, at the sole
65 | discretion of the dahliaOS Project Integrity Team:
66 |
67 | * a request for an apology;
68 | * a private or public warning or reprimand;
69 | * a temporary ban from the Discord server, blog, dahlia-os repository or
70 | organization, or other dahliaOS-supported communication group, including
71 | loss of committer status;
72 | * a permanent ban from any of the above, or from all current and future
73 | dahliaOS-supported communities, including loss of
74 | committer status.
75 |
76 | Participants warned to stop any harassing behavior are expected to comply
77 | immediately; failure to do so will result in an escalation of consequences.
78 |
79 | ## Acknowledgements
80 |
81 | This Code of Conduct is adapted from the Chromium Project Code of Conduct.
82 |
83 | ## License
84 |
85 | This Code of Conduct is available for reuse under the Creative Commons Zero
86 | (CC0) license.
87 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | dahliaOS is open to contributions. Any contribution is appreciated, whether it is a documentation update, localization, bug fix or a new feature. Anyone can contribute as long as they follow this guideline and obey the dahliaOS Code of Conduct.
4 | To make sure your contributions go as smooth as possible, here are all the things you need to know.
5 |
6 | ## Table of contents
7 |
8 | 1. **[Communication](#communication)**
9 | 1. **[Code of Conduct](#code-of-conduct)**
10 | 1. **[Contribute](#contribute)**
11 | 1. [Bug report](#bug-report)
12 | 1. [Before submitting a bug report](#before-submitting-a-bug-report)
13 | 1. [Writing a good bug report](#writing-a-good-bug-report)
14 | 1. [Submitting a bug report](#submitting-a-bug-report)
15 | 1. [Feature request](#feature-request)
16 | 1. [Before submitting a feature request](#before-submitting-a-feature-request)
17 | 1. [Submitting a feature request](#submitting-a-feature-request)
18 | 1. [Pull request](#pull-request)
19 | 1. [Before submitting a pull request](#before-submitting-a-pull-request)
20 | 1. [How to submit a proper pull request](#how-to-submit-a-proper-pull-request)
21 | 1. [After submitting a pull request](#after-submitting-a-pull-request)
22 | 1. [Translations](#translations)
23 | 1. [Before making a translation](#before-making-a-translation)
24 | 1. [How to translate](#how-to-translate)
25 | 1. [Code contributions](#code-contributions)
26 | 1. [First code contribution](#first-code-contribution)
27 | 1. [Design contributions](#design-contributions)
28 | 1. [Financial contributions](#financial-contributions)
29 | 1. [Finding tasks](#finding-tasks)
30 | 1. **[License](#license)**
31 |
32 | ## Communication
33 |
34 | Communication with core dahliaOS development team is crucial for any successful participation in dahliaOS development. There are several methods to communicate with the core team:
35 |
36 | * [Discord](https://dahliaos.io/discord) - We use Discord for pinging people, sharing updates, quick and informal discussions, questions and answers, etc. It is OK to discuss your contribution, planned contribution, development idea, localization, documentation updates and similar topics in this server. Anyone interested in the project is welcome to join our Discord server and hang around.
37 | * [Telegram](https://dahliaos.io/telegram) - Same as Discord.
38 | * [Issues / pull requests](https://github.com/dahliaOS) - Most of the work is discussed here, including upgrades and proposals for upgrades, bug fixing and feature requests. For any of these, open an issue in the corresponding repository. If you are proposing code change, open a pull request.
39 |
40 | Each of them is intended for an specific purpose. Please understand that you may be redirected to some other mean if the communication you intend to have is considered to fit better elsewhere.
41 |
42 | ## Code of Conduct
43 |
44 | This project and everyone participating in it is governed by our Code of Conduct and no one is exempt.
45 | By participating, you are expected to respect and value this code.
46 | dahliaOS Code of Conduct can be found [here](CODE_OF_CONDUCT.md).
47 | If you notice any unacceptable behaviour, we encourage you to report it to integrity@dahliaos.io
48 |
49 | ## Contribute
50 |
51 | In this document we've explained how you can contribute to our project, if you'd like to help out in a different way that is not documented here, you're always free to join our Discord and discuss other options you have in mind with our team.
52 |
53 | You can contribute to the project by:
54 |
55 | * Reporting a bug.
56 | * Proposing new features.
57 | * Translating to your native language.
58 | * Submitting a fix.
59 | * Discussing the current state of code.
60 | * Becoming a maintainer.
61 | * Making a financial contribution.
62 |
63 | ### Bug report
64 |
65 | If you've experienced a bug and you'd like to report it, we highly recommend that you read [Before submitting a bug report](#before-submitting-a-bug-report) and [Writing a good bug report](#writing-a-good-bug-report) first, and that you also use our issue template.
66 |
67 | There are 2 ways you can report a bug, either in our Discord server by **opening a ticket** or by **creating an issue** using the **bug report template** on GitHub.
68 |
69 | #### Before submitting a bug report
70 |
71 | Before submitting a bug report, there are a few things you need to take in consideration:
72 |
73 | * Do a bit of research and check if a similar bug has already been reported.
74 | * If it has been reported already, add a comment to the existing one instead of submitting a new one.
75 |
76 | #### Writing a good bug report
77 |
78 | We have a few short tips for you on how to properly write a bug report so the developers can understand it better:
79 |
80 | * Use a clear and descriptive title for the issue.
81 | * Describe the steps to reproduce the bug.
82 | * Describe what behaviour you observed after the bug occurred.
83 | * Explain what behaviour you expected to see instead and why.
84 | * If the problem wasn't triggered by a specific action, describe what you were doing before it happened.
85 | * Include screenshots of the bug.
86 | * Write what version of dahliaOS you were using.
87 |
88 | And the most important of all make sure to fill in as many fields as possible in our bug report template.
89 |
90 | #### Submitting a bug report
91 |
92 | * **GitHub**:
93 | 1. Click the **Issues** tab
94 | 1. Click **New issue**
95 | 1. Select the **Bug report** template
96 | 1. Fill in the fields
97 | * **Discord**:
98 | 1. Go to the **#bug-report** channel
99 | 1. Open a **ticket** and copy the **form**
100 | 1. Paste and fill in the form
101 |
102 | ### Feature request
103 |
104 | If you'd like to see something added to dahliaOS, we highly recommend that you read [Before submitting a feature request](#before-submitting-a-feature-request) and [Submitting a feature request](#submitting-a-feature-request) first, and that you also use our feature request template.
105 |
106 | To submit a feature request, **create an issue** using the **feature request template** on GitHub.
107 |
108 | #### Before submitting a feature request
109 |
110 | Before submitting a feature request, here are a few things you need to know:
111 |
112 | * Make sure the feature isn't already added.
113 | * Don't hesitate to express your knowledge.
114 | * Write a clear and descriptive title for the request.
115 | * Explain how the project could benefit of your request.
116 |
117 | #### Submitting a feature request
118 |
119 | * **GitHub**:
120 | 1. Click the **Issues** tab
121 | 1. Click **New issue**
122 | 1. Select the **Feature request** template
123 | 1. Fill in the fields
124 |
125 | ### Pull request
126 |
127 | Pull requests to our repositories are always welcome and can be a quick way to get your fix or improvement slated for the next release. In general, pull requests should:
128 |
129 | * Fix an existing issue or add a new feature.
130 | * Be accompanied by a complete pull request template (loaded automatically when a pull request is created).
131 |
132 | For changes that address core functionality or would require breaking changes (e.g. a major release), it's best to open an issue to discuss your proposal first. This is not required but can save time creating and reviewing changes.
133 |
134 | #### Before submitting a pull request
135 |
136 | To make sure that the pull request you want to submit is up to our standards, we've written a few dos and don'ts:
137 |
138 | **Dos**:
139 |
140 | * Provide a meaningful commit message.
141 | * The first line of the commit message should have the format "Category: Brief description of what's being changed". The "category" can be a subdirectory, but also something like "POSIX compliance" or "ClassName".
142 | * Write your commit messages in proper English, with care and punctuation.
143 | * Use the present tense ("Add feature" not "Added feature")
144 | * Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
145 | * Limit the first line to 72 characters or less
146 | * You may want to create a topic branch for larger contributions.
147 | * Split your changes into separate commits.
148 |
149 | **Don'ts**:
150 |
151 | * Touch anything outside the stated scope of the pull request.
152 | * Use weasel-words like "refactor" or "fix" to avoid explaining what's being changed.
153 |
154 | #### How to submit a proper pull request
155 |
156 | 1. **Fork** the repository to your own GitHub account
157 | 1. **Clone** the project to your machine
158 | 1. Make your **changes**
159 | 1. **Push** changes to your fork
160 | 1. **Open a pull request** in our repository and **fill** in the pull request template
161 |
162 | #### After submitting a pull request
163 |
164 | We kindly ask everyone who has submitted a pull request to be patient, we notice every new pull request so don't worry about it being ignored, we'll be on it as soon as possible.
165 |
166 | ### Translations
167 |
168 | We aim to provide our software in as many languages as possible so everyone could experience it in their own native language.
169 | For submitting translations, we use Crowdin so please do not edit the files found in the repositories.
170 | If you're interesting in translating our project, click [here](https://translate.dahliaos.io).
171 | **Note**: If the language you're looking to translate to is not added, let us know and we'll add it right away.
172 |
173 | #### Before making a translation
174 |
175 | Before making a translation, please make sure that:
176 |
177 | * You're fluent in the language you're translating to.
178 | * You pay close attention to grammar.
179 | * You read the context (comments) some strings have.
180 | * You used the same punctuation as the source strings.
181 |
182 | #### How to translate
183 |
184 | 1. Create a **Crowdin** account (if you already don't have one)
185 | 1. Join our **workspace**
186 | 1. Pick a **project** to translate
187 | 1. Apply translations to the available strings
188 |
189 | ### Code contributions
190 |
191 | To make sure that the code you want to contribute is up to our standards, we've written a few dos and don'ts:
192 |
193 | **Dos**:
194 |
195 | * Choose expressive variable, function and class names, make it as obvious as possible of what the code is doing.
196 |
197 | **Don'ts**:
198 |
199 | * Submit code that's incompatible with the project license (Apache 2.0).
200 | * Include commented-out code.
201 |
202 | #### First code contribution
203 |
204 | If you're not yet familiar with the development of dahliaOS, you can tackle tasks labeled with the "good first issue" label on our GitHub as they are more suited for newcomers looking to gain some experience.
205 |
206 | ### Design contributions
207 |
208 | Apart from code contributions, we also accept various kinds of design contributions.
209 |
210 | Here are a few repositories where you can contribute designs:
211 |
212 | * [wallpapers](https://github.com/dahliaos/wallpapers)
213 | * Contribute your own wallpapers made for dahliaOS.
214 | * [icons](https://github.com/dahliaos/icons)
215 | * Contribute/propose new or modified icons for dahliaOS.
216 | * [brand](https://github.com/dahliaos/brand)
217 | * Contribute/propose new or modified logos of our brand.
218 | * [press-kit](https://github.com/dahliaos/press-kit)
219 | * Contribute mockups, screenshots, graphics, marketing material and such for dahliaOS.
220 |
221 | We love seeing concepts and designs, feel free to share them with us on our social media!
222 |
223 | ### Financial contributions
224 |
225 | dahliaOS is an Apache 2.0-licensed free open source project that financially relies mainly on donations.
226 | Donations helps us pay the bills (web hosts, domains, software/hardware, etc.) to keep this project on its feet as long as possible.
227 | If you're interested in sending a donation to dahliaOS, click [here](https://dahliaos.io/donate) to find out where you can do so. Another way you can find donation links is by clicking the Sponsors button in most of our GitHub repositories.
228 |
229 | ### Finding tasks
230 |
231 | If you're interested in contributing to dahliaOS but don't know what you can assist us with, you can find available tasks by:
232 |
233 | * Peeking at GitHub issues / projects
234 | * Asking in our Discord or Telegram
235 |
236 | ## License
237 |
238 | By contributing to dahliaOS, you agree that your contributions will be licensed under the [Apache 2.0](LICENSE) license.
239 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # files
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:lint/analysis_options.yaml
2 |
3 | analyzer:
4 | exclude:
5 | - lib/generated_plugin_registrant.dart
6 | - lib/**/*.g.dart
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 |
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 30
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | defaultConfig {
36 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
37 | applicationId "com.example.files"
38 | minSdkVersion 16
39 | targetSdkVersion 30
40 | versionCode flutterVersionCode.toInteger()
41 | versionName flutterVersionName
42 | }
43 |
44 | buildTypes {
45 | release {
46 | // TODO: Add your own signing config for the release build.
47 | // Signing with the debug keys for now, so `flutter run --release` works.
48 | signingConfig signingConfigs.debug
49 | }
50 | }
51 | }
52 |
53 | flutter {
54 | source '../..'
55 | }
56 |
57 | dependencies {
58 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
59 | }
60 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
13 |
17 |
21 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
37 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/example/files/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.files
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:4.1.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | jcenter()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
7 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/dahliaOS/AppRun:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | exec $APPDIR/files $@
3 |
--------------------------------------------------------------------------------
/dahliaOS/appManifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "io.dahliaos.files",
3 | "altName": "files",
4 | "realName": "Files",
5 | "version": "dahliaOS-latest",
6 | "description": "File manager for dahliaOS",
7 | "sourceCode": "https://github.com/dahliaOS/files",
8 | "hash": "DAP_AUTOMATION_PKGHASH",
9 | "architecture": "x86_64"
10 | },
11 |
--------------------------------------------------------------------------------
/dahliaOS/files.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Name=Files
3 | Exec=files
4 | Terminal=false
5 | Icon=files
6 | Type=Application
7 | Categories=Utility;
8 |
--------------------------------------------------------------------------------
/dahliaOS/files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/dahliaOS/files.png
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | files
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/lib/backend/database/helper.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:files/backend/database/model.dart';
4 | import 'package:files/backend/providers.dart';
5 |
6 | class EntityStatCacheHelper {
7 | Future get(String path) async {
8 | final EntityStat? stat =
9 | isar.entityStats.where().pathEqualTo(path).findFirstSync();
10 |
11 | if (stat == null) {
12 | final EntityStat fetchedStat = EntityStat.fromStat(
13 | path,
14 | await FileStat.stat(path),
15 | );
16 | await set(fetchedStat);
17 | return fetchedStat;
18 | }
19 | return stat;
20 | }
21 |
22 | Future set(EntityStat entity) async {
23 | isar.writeTxn(() => isar.entityStats.put(entity));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/lib/backend/database/model.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:files/backend/providers.dart';
4 | import 'package:flutter/foundation.dart';
5 | import 'package:isar/isar.dart';
6 |
7 | export 'package:isar/isar.dart';
8 |
9 | part 'model.g.dart';
10 |
11 | @Collection()
12 | class EntityStat with ChangeNotifier {
13 | Id? id;
14 |
15 | @Index(unique: true, type: IndexType.hash)
16 | late String path;
17 |
18 | late DateTime changed;
19 | late DateTime modified;
20 | late DateTime accessed;
21 |
22 | @enumerated
23 | late EntityType type;
24 | late int mode;
25 | late int size;
26 |
27 | EntityStat();
28 |
29 | EntityStat.fastInit({
30 | required this.path,
31 | required this.changed,
32 | required this.modified,
33 | required this.accessed,
34 | required this.type,
35 | required this.mode,
36 | required this.size,
37 | });
38 |
39 | EntityStat.fromStat(String path, FileStat stat)
40 | : this.fastInit(
41 | path: path,
42 | changed: stat.changed,
43 | modified: stat.modified,
44 | accessed: stat.accessed,
45 | type: EntityType.fromDartIo(stat.type),
46 | mode: stat.mode,
47 | size: stat.size,
48 | );
49 |
50 | Future fetchUpdate() async {
51 | final FileStat ioStat = await FileStat.stat(path);
52 |
53 | if (!_statIdentical(ioStat)) {
54 | changed = ioStat.changed;
55 | modified = ioStat.modified;
56 | accessed = ioStat.accessed;
57 | type = EntityType.fromDartIo(ioStat.type);
58 | mode = ioStat.mode;
59 | size = ioStat.size;
60 | await helper.set(this);
61 | notifyListeners();
62 | }
63 | }
64 |
65 | bool _statIdentical(FileStat other) {
66 | return changed == other.changed &&
67 | modified == other.modified &&
68 | accessed == other.accessed &&
69 | type == EntityType.fromDartIo(other.type) &&
70 | mode == other.mode &&
71 | size == other.size;
72 | }
73 | }
74 |
75 | enum EntityType {
76 | file,
77 | directory,
78 | link,
79 | notFound;
80 |
81 | static EntityType fromDartIo(FileSystemEntityType type) {
82 | switch (type) {
83 | case FileSystemEntityType.file:
84 | return EntityType.file;
85 | case FileSystemEntityType.directory:
86 | return EntityType.directory;
87 | case FileSystemEntityType.link:
88 | return EntityType.link;
89 | case FileSystemEntityType.notFound:
90 | default:
91 | return EntityType.notFound;
92 | }
93 | }
94 |
95 | FileSystemEntityType get toDartIo {
96 | switch (this) {
97 | case EntityType.file:
98 | return FileSystemEntityType.file;
99 | case EntityType.directory:
100 | return FileSystemEntityType.directory;
101 | case EntityType.link:
102 | return FileSystemEntityType.link;
103 | case EntityType.notFound:
104 | return FileSystemEntityType.notFound;
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/lib/backend/entity_info.dart:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 The dahliaOS Authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import 'dart:io';
18 |
19 | import 'package:files/backend/database/model.dart';
20 |
21 | class EntityInfo {
22 | final FileSystemEntity _entity;
23 | final EntityStat stat;
24 | final EntityType entityType;
25 |
26 | const EntityInfo._(this._entity, this.stat, this.entityType);
27 |
28 | String get path => _entity.path;
29 |
30 | FileSystemEntity get entity => _entity;
31 |
32 | bool _equals(EntityInfo other) {
33 | return entity.path == other.entity.path &&
34 | stat.accessed == other.stat.accessed &&
35 | stat.changed == other.stat.changed &&
36 | stat.mode == other.stat.mode &&
37 | stat.modified == other.stat.modified &&
38 | stat.size == other.stat.size &&
39 | stat.type == other.stat.type &&
40 | entityType == other.entityType;
41 | }
42 |
43 | @override
44 | bool operator ==(Object? other) {
45 | if (other is EntityInfo) {
46 | return _equals(other);
47 | }
48 | return false;
49 | }
50 |
51 | @override
52 | int get hashCode => Object.hash(
53 | entity.path,
54 | stat.accessed,
55 | stat.changed,
56 | stat.mode,
57 | stat.modified,
58 | stat.size,
59 | stat.type,
60 | entityType,
61 | );
62 | }
63 |
64 | class FileEntityInfo extends EntityInfo {
65 | const FileEntityInfo({
66 | required File entity,
67 | required EntityStat stat,
68 | }) : super._(entity, stat, EntityType.file);
69 |
70 | @override
71 | File get entity => _entity as File;
72 | }
73 |
74 | class DirectoryEntityInfo extends EntityInfo {
75 | const DirectoryEntityInfo({
76 | required Directory entity,
77 | required EntityStat stat,
78 | }) : super._(entity, stat, EntityType.directory);
79 |
80 | @override
81 | Directory get entity => _entity as Directory;
82 | }
83 |
84 | enum EntityType {
85 | file,
86 | directory,
87 | }
88 |
89 | extension EntityInfoHelpers on EntityInfo {
90 | FileEntityInfo get asFile => this as FileEntityInfo;
91 | DirectoryEntityInfo get asDirectory => this as DirectoryEntityInfo;
92 |
93 | bool get isFile => this is FileEntityInfo;
94 | bool get isDirectory => this is DirectoryEntityInfo;
95 | }
96 |
97 | extension EntityInfoListHelpers on List {
98 | List get files => whereType().toList();
99 | List get directories =>
100 | whereType().toList();
101 | }
102 |
103 | /* class EntityStat implements Insertable {
104 | final String path;
105 | final DateTime changed;
106 | final DateTime modified;
107 | final DateTime accessed;
108 | final FileSystemEntityType type;
109 | final int mode;
110 | final int size;
111 |
112 | const EntityStat({
113 | required this.path,
114 | required this.changed,
115 | required this.modified,
116 | required this.accessed,
117 | required this.type,
118 | required this.mode,
119 | required this.size,
120 | });
121 |
122 | EntityStat.fromStat(String path, FileStat stat)
123 | : this(
124 | path: path,
125 | changed: stat.changed,
126 | modified: stat.modified,
127 | accessed: stat.accessed,
128 | type: stat.type,
129 | mode: stat.mode,
130 | size: stat.size,
131 | );
132 |
133 | @override
134 | Map toColumns(bool nullToAbsent) {
135 | return FileStatCachesCompanion(
136 | path: Value(path),
137 | changed: Value(changed),
138 | modified: Value(modified),
139 | accessed: Value(accessed),
140 | type: Value(type),
141 | mode: Value(mode),
142 | size: Value(size),
143 | ).toColumns(nullToAbsent);
144 | }
145 | } */
146 |
--------------------------------------------------------------------------------
/lib/backend/fetch.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:files/backend/entity_info.dart';
5 | import 'package:files/backend/providers.dart';
6 | import 'package:files/backend/utils.dart';
7 | import 'package:flutter/foundation.dart';
8 |
9 | enum SortType {
10 | name,
11 | modified,
12 | type,
13 | size,
14 | }
15 |
16 | class CancelableFsFetch {
17 | final Directory directory;
18 | final ValueChanged?> onFetched;
19 | final VoidCallback? onCancel;
20 | final ValueChanged? onProgressChange;
21 | final ValueChanged? onFileSystemException;
22 | final bool ascending;
23 | final SortType sortType;
24 | final bool showHidden;
25 |
26 | CancelableFsFetch({
27 | required this.directory,
28 | required this.onFetched,
29 | this.onCancel,
30 | this.onProgressChange,
31 | this.onFileSystemException,
32 | this.ascending = false,
33 | this.sortType = SortType.name,
34 | this.showHidden = false,
35 | });
36 |
37 | bool _running = false;
38 | Completer cancelableCompleter = Completer();
39 | bool _cancelled = false;
40 | bool get cancelled => _cancelled;
41 |
42 | Future startFetch() async {
43 | if (_cancelled) throw CancelledException();
44 |
45 | onProgressChange?.call(0.0);
46 | late final List list;
47 | try {
48 | list = await directory
49 | .list()
50 | .where(
51 | (element) =>
52 | !Utils.getEntityName(element.path).startsWith(".") ||
53 | showHidden,
54 | )
55 | .toList();
56 | } on FileSystemException catch (e) {
57 | onFileSystemException?.call(e.osError);
58 | _cancelled = true;
59 | return;
60 | }
61 | final List directories = [];
62 | final List files = [];
63 |
64 | _running = true;
65 | for (int i = 0; i < list.length; i++) {
66 | if (_cancelled) {
67 | onCancel?.call();
68 | cancelableCompleter.complete();
69 | return;
70 | }
71 |
72 | late final EntityInfo info;
73 |
74 | if (list[i] is Directory) {
75 | info = DirectoryEntityInfo(
76 | entity: list[i] as Directory,
77 | stat: await cacheProxy.get(list[i].path),
78 | );
79 | directories.add(info);
80 | } else if (list[i] is File) {
81 | info = FileEntityInfo(
82 | entity: list[i] as File,
83 | stat: await cacheProxy.get(list[i].path),
84 | );
85 | files.add(info);
86 | } else if (list[i] is Link) {
87 | (list[i] as Link).path;
88 | }
89 |
90 | onProgressChange?.call((i + 1) / list.length);
91 | }
92 | _running = false;
93 |
94 | directories.sort((a, b) => _sort(a, b, isDirectory: true)!);
95 | files.sort((a, b) => _sort(a, b)!);
96 |
97 | onProgressChange?.call(null);
98 |
99 | if (!_cancelled) onFetched.call([...directories, ...files]);
100 | }
101 |
102 | int? _sort(
103 | EntityInfo a,
104 | EntityInfo b, {
105 | bool isDirectory = false,
106 | }) {
107 | EntityInfo item1 = a;
108 | EntityInfo item2 = b;
109 |
110 | if (!ascending) {
111 | item2 = a;
112 | item1 = b;
113 | }
114 |
115 | switch (sortType.index) {
116 | case 0:
117 | return Utils.getEntityName(item1.path.toLowerCase())
118 | .compareTo(Utils.getEntityName(item2.path.toLowerCase()));
119 | case 1:
120 | return item1.stat.modified.compareTo(item2.stat.modified);
121 | case 2:
122 | return 0;
123 | case 3:
124 | if (isDirectory) {
125 | return 0;
126 | } else {
127 | return item1.stat.size.compareTo(item2.stat.size);
128 | }
129 | }
130 |
131 | return null;
132 | }
133 |
134 | Future cancel() async {
135 | if (!_running) return;
136 | _cancelled = true;
137 | await cancelableCompleter.future;
138 | }
139 | }
140 |
141 | class CancelledException implements Exception {
142 | @override
143 | String toString() {
144 | return "CancelledException: The fetch was cancelled and can't be restored, please create a new instance for fetching.";
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/lib/backend/folder_provider.dart:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 The dahliaOS Authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import 'dart:io';
18 |
19 | import 'package:collection/collection.dart';
20 | import 'package:files/backend/utils.dart';
21 | import 'package:flutter/material.dart';
22 | import 'package:windows_path_provider/windows_path_provider.dart';
23 | import 'package:xdg_directories/xdg_directories.dart';
24 |
25 | class FolderProvider {
26 | final List _folders;
27 | final List _destinations;
28 |
29 | List get folders => List.from(_folders);
30 | List get destinations => List.from(_destinations);
31 |
32 | static Future init() async {
33 | final List folders = [];
34 |
35 | if (Platform.isWindows) {
36 | for (final WindowsFolder folder in WindowsFolder.values) {
37 | final String? path = await WindowsPathProvider.getPath(folder);
38 |
39 | if (path == null) continue;
40 |
41 | final FolderType? type = folder.toFolderType();
42 | if (type == null) continue;
43 |
44 | folders.add(BuiltinFolder(type, Directory(path)));
45 | }
46 | } else if (Platform.isLinux) {
47 | final Set dirNames = getUserDirectoryNames();
48 |
49 | final List backDir = getUserDirectory(dirNames.first)!
50 | .path
51 | .split(Platform.pathSeparator)
52 | ..removeLast();
53 | folders.add(
54 | BuiltinFolder(
55 | FolderType.home,
56 | Directory(backDir.join(Platform.pathSeparator)),
57 | ),
58 | );
59 |
60 | for (final String element in dirNames) {
61 | final FolderType? type = FolderType.fromString(element);
62 | if (type == null) continue;
63 |
64 | folders.add(
65 | BuiltinFolder(
66 | type,
67 | Directory(getUserDirectory(element)!.path),
68 | ),
69 | );
70 | }
71 | } else {
72 | throw Exception("Platform not supported");
73 | }
74 |
75 | final List destinations = [
76 | for (final BuiltinFolder element in folders)
77 | SideDestination(
78 | _icons[element.type]!,
79 | Utils.getEntityName(element.directory.path),
80 | element.directory.path,
81 | ),
82 | ];
83 |
84 | return FolderProvider._(folders, destinations);
85 | }
86 |
87 | const FolderProvider._(this._folders, this._destinations);
88 |
89 | IconData getIconForType(FolderType type) {
90 | return _icons[type]!;
91 | }
92 |
93 | BuiltinFolder? isBuiltinFolder(String path) {
94 | return _folders.firstWhereOrNull((v) => v.directory.path == path);
95 | }
96 | }
97 |
98 | enum FolderType {
99 | home,
100 | desktop,
101 | documents,
102 | pictures,
103 | download,
104 | videos,
105 | music,
106 | publicShare,
107 | templates;
108 |
109 | static FolderType? fromString(String value) {
110 | return FolderType.values
111 | .asNameMap()
112 | .map((k, v) => MapEntry(k.toUpperCase(), v))[value.toUpperCase()];
113 | }
114 | }
115 |
116 | class BuiltinFolder {
117 | final FolderType type;
118 | final Directory directory;
119 |
120 | const BuiltinFolder(this.type, this.directory);
121 | }
122 |
123 | class SideDestination {
124 | final IconData icon;
125 | final String label;
126 | final String path;
127 |
128 | const SideDestination(this.icon, this.label, this.path);
129 | }
130 |
131 | const Map _icons = {
132 | FolderType.home: Icons.home_filled,
133 | FolderType.desktop: Icons.desktop_windows,
134 | FolderType.documents: Icons.note_outlined,
135 | FolderType.pictures: Icons.photo_library_outlined,
136 | FolderType.download: Icons.file_download,
137 | FolderType.videos: Icons.videocam_outlined,
138 | FolderType.music: Icons.music_note_outlined,
139 | FolderType.publicShare: Icons.public_outlined,
140 | FolderType.templates: Icons.file_copy_outlined,
141 | };
142 |
143 | String windowsFolderToString(WindowsFolder folder) {
144 | switch (folder) {
145 | case WindowsFolder.profile:
146 | return "HOME";
147 | case WindowsFolder.desktop:
148 | return "DESKTOP";
149 | case WindowsFolder.documents:
150 | return "DOCUMENTS";
151 | case WindowsFolder.pictures:
152 | return "PICTURES";
153 | case WindowsFolder.downloads:
154 | return "DOWNLOAD";
155 | case WindowsFolder.videos:
156 | return "VIDEOS";
157 | case WindowsFolder.music:
158 | return "MUSIC";
159 | case WindowsFolder.public:
160 | return "PUBLICSHARE";
161 | case WindowsFolder.templates:
162 | return "TEMPLATES";
163 | }
164 | }
165 |
166 | extension on WindowsFolder {
167 | FolderType? toFolderType() {
168 | switch (this) {
169 | case WindowsFolder.profile:
170 | return FolderType.home;
171 | case WindowsFolder.public:
172 | return FolderType.publicShare;
173 | default:
174 | return FolderType.fromString(name);
175 | }
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/lib/backend/path_parts.dart:
--------------------------------------------------------------------------------
1 | class PathParts {
2 | final String root;
3 | final List parts;
4 | final String separator;
5 |
6 | const PathParts(this.root, this.parts, this.separator);
7 |
8 | factory PathParts.parse(String path) {
9 | late final String root;
10 | late final String separator;
11 |
12 | if (path.startsWith("/")) {
13 | root = "/";
14 | separator = "/";
15 | } else if (path.startsWith(RegExp(r"[A-Z]:\\", caseSensitive: false))) {
16 | root = RegExp(r"^[A-Z]:\\", caseSensitive: false)
17 | .firstMatch(path)!
18 | .group(0)!;
19 | separator = "\\";
20 | }
21 | final String cleanPath = path.replaceFirst(root, "");
22 |
23 | late final List parts;
24 | if (cleanPath.isNotEmpty) {
25 | parts = path.replaceFirst(root, "").split(separator);
26 | } else {
27 | parts = [];
28 | }
29 |
30 | return PathParts(root, parts, separator);
31 | }
32 |
33 | String toPath([int? numOfParts]) {
34 | final int resolvedNumOfParts = numOfParts ?? parts.length;
35 | assert(resolvedNumOfParts >= 0 && resolvedNumOfParts <= parts.length);
36 | final List transformedPathParts =
37 | parts.sublist(0, resolvedNumOfParts);
38 | final String path = transformedPathParts.join(separator);
39 |
40 | return "$root$path";
41 | }
42 |
43 | PathParts trim(int numOfParts) {
44 | assert(numOfParts >= 0 && numOfParts <= parts.length);
45 | final List transformedPathParts = parts.sublist(0, numOfParts);
46 |
47 | return PathParts(root, transformedPathParts, separator);
48 | }
49 |
50 | List get integralParts => [root, ...parts];
51 |
52 | @override
53 | String toString() {
54 | return {
55 | "root": root,
56 | "parts": parts,
57 | "separator": separator,
58 | }.toString();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/lib/backend/providers.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:files/backend/database/helper.dart';
4 | import 'package:files/backend/database/model.dart';
5 | import 'package:files/backend/folder_provider.dart';
6 | import 'package:files/backend/stat_cache_proxy.dart';
7 | import 'package:path/path.dart' as p;
8 | import 'package:path_provider/path_provider.dart';
9 | import 'package:ubuntu_service/ubuntu_service.dart';
10 |
11 | String _isarPath(Directory dir) {
12 | final String path = p.join(dir.path, 'isar');
13 | if (!Directory(path).existsSync()) Directory(path).create();
14 | return path;
15 | }
16 |
17 | Future initProviders() async {
18 | final dir = await getApplicationDocumentsDirectory();
19 | final isar = await Isar.open(
20 | [EntityStatSchema],
21 | directory: _isarPath(dir),
22 | inspector: false,
23 | );
24 | final folderProvider = await FolderProvider.init();
25 |
26 | registerServiceInstance(isar);
27 | registerServiceInstance(folderProvider);
28 | registerService(EntityStatCacheHelper.new);
29 | registerService(StatCacheProxy.new);
30 | }
31 |
32 | Isar get isar => getService();
33 |
34 | FolderProvider get folderProvider => getService();
35 |
36 | EntityStatCacheHelper get helper => getService();
37 |
38 | StatCacheProxy get cacheProxy => getService();
39 |
--------------------------------------------------------------------------------
/lib/backend/stat_cache_proxy.dart:
--------------------------------------------------------------------------------
1 | import 'package:files/backend/database/model.dart';
2 | import 'package:files/backend/providers.dart';
3 |
4 | class StatCacheProxy {
5 | final Map _runtimeCache = {};
6 |
7 | StatCacheProxy();
8 |
9 | Future get(String path) async {
10 | if (!_runtimeCache.containsKey(path)) {
11 | final stat = await helper.get(path)
12 | ..fetchUpdate();
13 | _runtimeCache[path] = stat;
14 | return stat;
15 | }
16 |
17 | return _runtimeCache[path]!..fetchUpdate();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/lib/backend/utils.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:files/backend/folder_provider.dart';
4 | import 'package:files/backend/path_parts.dart';
5 | import 'package:files/backend/providers.dart';
6 | import 'package:flutter/material.dart';
7 | import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
8 | import 'package:mime/mime.dart';
9 |
10 | class Utils {
11 | Utils._();
12 |
13 | static Map get iconsPerMime => {
14 | "application/java-archive": MdiIcons.languageJava,
15 | "application/json": MdiIcons.codeBraces,
16 | "application/msword": MdiIcons.fileWordOutline,
17 | "application/octet-stream": MdiIcons.fileDocumentOutline,
18 | "application/pdf": MdiIcons.fileDocumentOutline,
19 | "application/vnd.microsoft.portable-executable":
20 | MdiIcons.microsoftWindows,
21 | "application/vnd.ms-excel": MdiIcons.fileExcelOutline,
22 | "application/vnd.ms-powerpoint": MdiIcons.filePowerpointOutline,
23 | "application/vnd.openxmlformats-officedocument.presentationml.presentation":
24 | MdiIcons.filePowerpointOutline,
25 | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
26 | MdiIcons.fileExcelOutline,
27 | "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
28 | MdiIcons.fileWordOutline,
29 | "application/vnd.rar": MdiIcons.zipBoxOutline,
30 | "application/x-7z-compressed": MdiIcons.zipBoxOutline,
31 | "application/x-iso9660-image": MdiIcons.disc,
32 | "application/x-msdownload": MdiIcons.microsoftWindows,
33 | "application/x-rar-compressed": MdiIcons.zipBoxOutline,
34 | "application/x-sql": MdiIcons.databaseOutline,
35 | "application/zip": MdiIcons.zipBoxOutline,
36 | "audio/mpeg": MdiIcons.fileMusicOutline,
37 | "audio/ogg": MdiIcons.fileMusicOutline,
38 | "image/gif": Icons.animation,
39 | "image/jpeg": MdiIcons.fileImageOutline,
40 | "image/png": MdiIcons.fileImageOutline,
41 | "image/svg+xml": MdiIcons.svg,
42 | "text/css": MdiIcons.fileCodeOutline,
43 | "text/csv": MdiIcons.fileDocumentOutline,
44 | "text/javascript": MdiIcons.languageJavascript,
45 | "text/html": MdiIcons.languageHtml5,
46 | "text/plain": MdiIcons.fileDocumentOutline,
47 | "video/mp4": MdiIcons.fileVideoOutline,
48 | "video/ogg": MdiIcons.fileVideoOutline,
49 | };
50 |
51 | static IconData iconForPath(String path) {
52 | final String? mime = lookupMimeType(path);
53 |
54 | if (mime != null) {
55 | return iconsPerMime[mime] ?? Icons.insert_drive_file_outlined;
56 | }
57 |
58 | return Icons.insert_drive_file_outlined;
59 | }
60 |
61 | static IconData iconForFolder(String path) {
62 | final BuiltinFolder? builtinFolder = folderProvider.isBuiltinFolder(path);
63 | final IconData? builtinFolderIcon = builtinFolder != null
64 | ? folderProvider.getIconForType(builtinFolder.type)
65 | : null;
66 |
67 | return builtinFolderIcon ?? Icons.folder;
68 | }
69 |
70 | static String getEntityName(String path) {
71 | final PathParts pathParts = PathParts.parse(path);
72 | return pathParts.integralParts.last;
73 | }
74 |
75 | static void moveFileToDest(FileSystemEntity origin, String dest) {
76 | final originParts = PathParts.parse(origin.path);
77 | final directoryParts = PathParts.parse(dest);
78 | final destinationParts = PathParts(
79 | originParts.root,
80 | directoryParts.parts..add(originParts.parts.last),
81 | originParts.separator,
82 | );
83 | origin.rename(destinationParts.toPath());
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/lib/backend/workspace.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:files/backend/entity_info.dart';
5 | import 'package:files/backend/fetch.dart';
6 | import 'package:flutter/widgets.dart';
7 | import 'package:provider/provider.dart';
8 |
9 | enum WorkspaceView { table, grid }
10 |
11 | class WorkspaceController with ChangeNotifier {
12 | WorkspaceController({required String initialDir}) {
13 | _resetStates();
14 | changeCurrentDir(initialDir);
15 | }
16 |
17 | // Scroll cache
18 | double lastHorizontalScrollOffset = 0.0;
19 | double lastVerticalScrollOffset = 0.0;
20 |
21 | // Private utilities
22 | CancelableFsFetch? _fetcher;
23 | StreamSubscription? _directoryStream;
24 |
25 | // Loading related
26 | late String _currentDir;
27 | List? _currentInfo;
28 | double? _loadingProgress;
29 | OSError? _lastError;
30 |
31 | // Sort, view and selection
32 | bool _ascending = true;
33 | bool _showHidden = false;
34 | SortType _sortType = SortType.name;
35 | WorkspaceView _view = WorkspaceView.table; // save on SharedPreferences?
36 | final List _selectedItems = [];
37 |
38 | // States
39 | late TableViewState _tableState;
40 | late GridViewState _gridState;
41 |
42 | // Navigation history
43 | final List _history = [];
44 | int _historyOffset = 0;
45 |
46 | void _resetStates() {
47 | _tableState = const TableViewState(
48 | firstWidth: 480,
49 | secondWidth: 180,
50 | thirdWidth: 120,
51 | fourthWidth: 120,
52 | );
53 | _gridState = const GridViewState(size: 96);
54 | }
55 |
56 | Future getInfoForDir(Directory dir) async {
57 | await _fetcher?.cancel();
58 | _lastError = null;
59 | _fetcher = CancelableFsFetch(
60 | directory: dir,
61 | onFetched: (data) {
62 | _currentInfo = data;
63 | notifyListeners();
64 | },
65 | onProgressChange: (value) {
66 | _loadingProgress = value;
67 | notifyListeners();
68 | },
69 | showHidden: _showHidden,
70 | ascending: _ascending,
71 | sortType: _sortType,
72 | onFileSystemException: (value) {
73 | _lastError = value;
74 | notifyListeners();
75 | },
76 | );
77 | await _fetcher!.startFetch();
78 | }
79 |
80 | List? get currentInfo =>
81 | _currentInfo != null ? List.unmodifiable(_currentInfo!) : null;
82 | double? get loadingProgress => _loadingProgress;
83 |
84 | void clearCurrentInfo() {
85 | _currentInfo = null;
86 | notifyListeners();
87 | }
88 |
89 | String get currentDir => _currentDir;
90 |
91 | bool get ascending => _ascending;
92 | set ascending(bool value) {
93 | _ascending = value;
94 | notifyListeners();
95 | }
96 |
97 | bool get showHidden => _showHidden;
98 | set showHidden(bool value) {
99 | _showHidden = value;
100 | notifyListeners();
101 | }
102 |
103 | SortType get sortType => _sortType;
104 | set sortType(SortType value) {
105 | _sortType = value;
106 | notifyListeners();
107 | }
108 |
109 | WorkspaceView get view => _view;
110 | set view(WorkspaceView value) {
111 | _view = value;
112 | notifyListeners();
113 | }
114 |
115 | TableViewState get tableState => _tableState;
116 | void setTableState(TableViewState state) {
117 | _tableState = state;
118 | notifyListeners();
119 | }
120 |
121 | GridViewState get gridState => _gridState;
122 | void setGridState(GridViewState state) {
123 | _gridState = state;
124 | notifyListeners();
125 | }
126 |
127 | List get selectedItems => List.unmodifiable(_selectedItems);
128 | void addSelectedItem(EntityInfo info) {
129 | _selectedItems.add(info);
130 | notifyListeners();
131 | }
132 |
133 | void removeSelectedItem(EntityInfo info) {
134 | _selectedItems.remove(info);
135 | notifyListeners();
136 | }
137 |
138 | void clearSelectedItems() {
139 | _selectedItems.clear();
140 | notifyListeners();
141 | }
142 |
143 | List get history => List.from(_history);
144 | int get historyOffset => _historyOffset;
145 |
146 | OSError? get lastError => _lastError;
147 |
148 | Future changeCurrentDir(
149 | String newDir, {
150 | bool updateHistory = true,
151 | }) async {
152 | _currentDir = newDir;
153 |
154 | if (updateHistory) {
155 | if (_historyOffset != 0) {
156 | final List validHistory =
157 | _history.reversed.toList().sublist(_historyOffset);
158 | _history.clear();
159 | _history.addAll(validHistory.reversed);
160 | _historyOffset = 0;
161 | }
162 | _history.add(_currentDir);
163 | }
164 |
165 | clearCurrentInfo();
166 | clearSelectedItems();
167 | await _directoryStream?.cancel();
168 | await getInfoForDir(Directory(newDir));
169 | _directoryStream =
170 | Directory(newDir).watch().listen(_directoryStreamListener);
171 | }
172 |
173 | void setHistoryOffset(int offset) {
174 | _historyOffset = 0; // hack
175 | changeCurrentDir(_history.reversed.toList()[offset], updateHistory: false);
176 | _historyOffset = offset;
177 |
178 | notifyListeners();
179 | }
180 |
181 | void goToPreviousHistoryEntry() => setHistoryOffset(_historyOffset + 1);
182 | void goToNextHistoryEntry() => setHistoryOffset(_historyOffset - 1);
183 |
184 | bool get canGoToPreviousHistoryEntry =>
185 | _history.length > 1 && _historyOffset < _history.length - 1;
186 | bool get canGoToNextHistoryEntry => _historyOffset != 0;
187 |
188 | Future _directoryStreamListener(FileSystemEvent event) async {
189 | await getInfoForDir(Directory(currentDir));
190 | }
191 |
192 | static WorkspaceController of(BuildContext context, {bool listen = true}) {
193 | return Provider.of(context, listen: listen);
194 | }
195 | }
196 |
197 | class TableViewState {
198 | final double firstWidth;
199 | final double secondWidth;
200 | final double thirdWidth;
201 | final double fourthWidth;
202 |
203 | const TableViewState({
204 | required this.firstWidth,
205 | required this.secondWidth,
206 | required this.thirdWidth,
207 | required this.fourthWidth,
208 | });
209 |
210 | List get widths => [
211 | firstWidth,
212 | secondWidth,
213 | thirdWidth,
214 | fourthWidth,
215 | ];
216 |
217 | TableViewState copyWith({
218 | double? firstWidth,
219 | double? secondWidth,
220 | double? thirdWidth,
221 | double? fourthWidth,
222 | }) {
223 | return TableViewState(
224 | firstWidth: firstWidth ?? this.firstWidth,
225 | secondWidth: secondWidth ?? this.secondWidth,
226 | thirdWidth: thirdWidth ?? this.thirdWidth,
227 | fourthWidth: fourthWidth ?? this.fourthWidth,
228 | );
229 | }
230 |
231 | TableViewState applyDeltaToWidth(int index, double delta) {
232 | switch (index) {
233 | case 0:
234 | return copyWith(firstWidth: firstWidth + delta);
235 | case 1:
236 | return copyWith(secondWidth: secondWidth + delta);
237 | case 2:
238 | return copyWith(thirdWidth: thirdWidth + delta);
239 | case 3:
240 | return copyWith(fourthWidth: fourthWidth + delta);
241 | }
242 |
243 | throw RangeError.index(index, widths);
244 | }
245 | }
246 |
247 | class GridViewState {
248 | final double size;
249 |
250 | const GridViewState({
251 | required this.size,
252 | });
253 | }
254 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2019 The dahliaOS Authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | import 'package:files/backend/providers.dart';
18 | import 'package:files/backend/workspace.dart';
19 | import 'package:files/widgets/side_pane.dart';
20 | import 'package:files/widgets/tab_strip.dart';
21 | import 'package:files/widgets/workspace.dart';
22 | import 'package:flutter/material.dart';
23 |
24 | Future main() async {
25 | WidgetsFlutterBinding.ensureInitialized();
26 | await initProviders();
27 |
28 | runApp(const Files());
29 | }
30 |
31 | class Files extends StatelessWidget {
32 | const Files({super.key});
33 |
34 | @override
35 | Widget build(BuildContext context) {
36 | return MaterialApp(
37 | title: 'Files',
38 | theme: ThemeData(
39 | colorScheme: const ColorScheme(
40 | primary: Colors.deepOrange,
41 | secondary: Colors.deepOrange,
42 | background: Color(0xFF161616),
43 | surface: Color(0xFF212121),
44 | error: Colors.red,
45 | onPrimary: Colors.white,
46 | onSecondary: Colors.white,
47 | onBackground: Colors.white,
48 | onSurface: Colors.white,
49 | onError: Colors.white,
50 | brightness: Brightness.dark,
51 | ),
52 | scrollbarTheme: ScrollbarThemeData(
53 | thumbVisibility: const MaterialStatePropertyAll(true),
54 | trackVisibility: MaterialStateProperty.resolveWith(
55 | (states) => states.contains(MaterialState.hovered),
56 | ),
57 | trackBorderColor: MaterialStateProperty.all(Colors.transparent),
58 | crossAxisMargin: 0,
59 | mainAxisMargin: 0,
60 | radius: Radius.zero,
61 | ),
62 | menuTheme: const MenuThemeData(
63 | style: MenuStyle(
64 | padding: MaterialStatePropertyAll(
65 | EdgeInsets.symmetric(vertical: 16),
66 | ),
67 | ),
68 | ),
69 | ),
70 | scrollBehavior: const MaterialScrollBehavior().copyWith(
71 | scrollbars: false,
72 | ),
73 | debugShowCheckedModeBanner: false,
74 | home: const FilesHome(),
75 | );
76 | }
77 | }
78 |
79 | class FilesHome extends StatefulWidget {
80 | const FilesHome({super.key});
81 |
82 | @override
83 | _FilesHomeState createState() => _FilesHomeState();
84 | }
85 |
86 | class _FilesHomeState extends State {
87 | late final List workspaces = [
88 | WorkspaceController(initialDir: folderProvider.destinations.first.path),
89 | ];
90 | int currentWorkspace = 0;
91 |
92 | String get currentDir => workspaces[currentWorkspace].currentDir;
93 |
94 | @override
95 | Widget build(BuildContext context) {
96 | return Row(
97 | children: [
98 | SidePane(
99 | destinations: folderProvider.destinations,
100 | workspace: workspaces[currentWorkspace],
101 | onNewTab: (String tabPath) {
102 | workspaces.add(WorkspaceController(initialDir: tabPath));
103 | currentWorkspace = workspaces.length - 1;
104 | setState(() {});
105 | },
106 | ),
107 | Expanded(
108 | child: Material(
109 | color: Theme.of(context).colorScheme.background,
110 | child: Column(
111 | children: [
112 | SizedBox(
113 | height: 56,
114 | child: TabStrip(
115 | tabs: workspaces,
116 | selectedTab: currentWorkspace,
117 | allowClosing: workspaces.length > 1,
118 | onTabChanged: (index) =>
119 | setState(() => currentWorkspace = index),
120 | onTabClosed: (index) {
121 | workspaces.removeAt(index);
122 | if (index < workspaces.length) {
123 | currentWorkspace = index;
124 | } else if (index - 1 >= 0) {
125 | currentWorkspace = index - 1;
126 | }
127 | setState(() {});
128 | },
129 | onNewTab: () {
130 | workspaces
131 | .add(WorkspaceController(initialDir: currentDir));
132 | currentWorkspace = workspaces.length - 1;
133 | setState(() {});
134 | },
135 | ),
136 | ),
137 | Expanded(
138 | child: FilesWorkspace(
139 | key: ValueKey(currentWorkspace),
140 | controller: workspaces[currentWorkspace],
141 | ),
142 | ),
143 | ],
144 | ),
145 | ),
146 | ),
147 | ],
148 | );
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/lib/widgets/breadcrumbs_bar.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:collection/collection.dart';
4 | import 'package:files/backend/folder_provider.dart';
5 | import 'package:files/backend/path_parts.dart';
6 | import 'package:files/backend/providers.dart';
7 | import 'package:files/backend/utils.dart';
8 | import 'package:flutter/material.dart';
9 |
10 | class BreadcrumbsBar extends StatefulWidget {
11 | final PathParts path;
12 | final ValueChanged? onBreadcrumbPress;
13 | final ValueChanged? onPathSubmitted;
14 | final List? leading;
15 | final List? actions;
16 | final double? loadingProgress;
17 |
18 | const BreadcrumbsBar({
19 | required this.path,
20 | this.onBreadcrumbPress,
21 | this.onPathSubmitted,
22 | this.leading,
23 | this.actions,
24 | this.loadingProgress,
25 | super.key,
26 | });
27 |
28 | @override
29 | State createState() => _BreadcrumbsBarState();
30 | }
31 |
32 | class _BreadcrumbsBarState extends State {
33 | final TextEditingController controller = TextEditingController();
34 | final FocusNode focusNode = FocusNode();
35 |
36 | @override
37 | void initState() {
38 | super.initState();
39 | _updateText();
40 | focusNode.addListener(() {
41 | if (focusNode.hasFocus) {
42 | controller.selection = TextSelection(
43 | baseOffset: 0,
44 | extentOffset: controller.text.length,
45 | );
46 | }
47 | });
48 | }
49 |
50 | @override
51 | void didUpdateWidget(covariant BreadcrumbsBar old) {
52 | super.didUpdateWidget(old);
53 |
54 | if (widget.path != old.path) {
55 | _updateText();
56 | setState(() {});
57 | }
58 | }
59 |
60 | void _updateText() {
61 | controller.text = widget.path.toPath();
62 | }
63 |
64 | @override
65 | Widget build(BuildContext context) {
66 | return SizedBox.expand(
67 | child: Material(
68 | color: Theme.of(context).colorScheme.background,
69 | child: SizedBox.expand(
70 | child: Row(
71 | children: [
72 | if (widget.leading != null) const SizedBox(width: 8),
73 | if (widget.leading != null) ...widget.leading!,
74 | Expanded(
75 | child: Padding(
76 | padding: const EdgeInsets.all(8.0),
77 | child: Material(
78 | color: Theme.of(context).colorScheme.surface,
79 | shape: RoundedRectangleBorder(
80 | borderRadius: BorderRadius.circular(4),
81 | ),
82 | clipBehavior: Clip.antiAlias,
83 | child: _LoadingIndicator(
84 | progress: widget.loadingProgress,
85 | child: GestureDetector(
86 | onTap: () {
87 | FocusScope.of(context).requestFocus(focusNode);
88 | },
89 | child: Container(
90 | height: double.infinity,
91 | alignment: AlignmentDirectional.centerStart,
92 | child: _guts,
93 | ),
94 | ),
95 | ),
96 | ),
97 | ),
98 | ),
99 | if (widget.actions != null) ...widget.actions!,
100 | if (widget.actions != null) const SizedBox(width: 8),
101 | ],
102 | ),
103 | ),
104 | ),
105 | );
106 | }
107 |
108 | Widget get _guts {
109 | if (focusNode.hasFocus) {
110 | return TextField(
111 | decoration: const InputDecoration(
112 | border: InputBorder.none,
113 | contentPadding: EdgeInsets.symmetric(horizontal: 8),
114 | isCollapsed: true,
115 | ),
116 | focusNode: focusNode,
117 | controller: controller,
118 | style: const TextStyle(fontSize: 14),
119 | onSubmitted: widget.onPathSubmitted,
120 | );
121 | } else {
122 | final List actualParts;
123 |
124 | // We need home folder on last position here to emulate a low priority entry
125 | final List sortedFolders = folderProvider.folders;
126 | final int homeIndex =
127 | sortedFolders.indexWhere((e) => e.type == FolderType.home);
128 | sortedFolders.add(sortedFolders.removeAt(homeIndex));
129 |
130 | final BuiltinFolder? builtinFolder = sortedFolders.firstWhereOrNull(
131 | (e) => widget.path.toPath().startsWith(e.directory.path),
132 | );
133 |
134 | if (builtinFolder != null) {
135 | final PathParts builtinParts =
136 | PathParts.parse(builtinFolder.directory.path);
137 | actualParts = [
138 | builtinParts,
139 | ...List.generate(
140 | widget.path.integralParts.length -
141 | builtinParts.integralParts.length,
142 | (index) =>
143 | widget.path.trim(index + builtinParts.integralParts.length),
144 | ),
145 | ];
146 | } else {
147 | actualParts = List.generate(
148 | widget.path.integralParts.length,
149 | (index) => widget.path.trim(index),
150 | );
151 | }
152 |
153 | return ListView.separated(
154 | scrollDirection: Axis.horizontal,
155 | itemBuilder: (context, index) {
156 | final bool isInsideBuiltin = builtinFolder != null &&
157 | actualParts[index].toPath() == builtinFolder.directory.path;
158 |
159 | return _BreadcrumbChip(
160 | path: actualParts[index],
161 | onTap: widget.onBreadcrumbPress,
162 | childOverride: isInsideBuiltin
163 | ? Row(
164 | children: [
165 | Icon(
166 | folderProvider.getIconForType(builtinFolder.type),
167 | size: 16,
168 | ),
169 | const SizedBox(width: 8),
170 | Text(Utils.getEntityName(builtinFolder.directory.path)),
171 | ],
172 | )
173 | : null,
174 | );
175 | },
176 | itemCount: actualParts.length,
177 | separatorBuilder: (context, index) => const VerticalDivider(width: 2),
178 | );
179 | }
180 | }
181 | }
182 |
183 | class _BreadcrumbChip extends StatelessWidget {
184 | const _BreadcrumbChip({
185 | required this.path,
186 | this.onTap,
187 | this.childOverride,
188 | });
189 |
190 | final PathParts path;
191 | final ValueChanged? onTap;
192 | final Widget? childOverride;
193 |
194 | @override
195 | Widget build(BuildContext context) {
196 | return SizedBox(
197 | height: double.infinity,
198 | child: DragTarget(
199 | onAccept: (data) => Utils.moveFileToDest(data, path.toPath()),
200 | builder: (context, candidateData, rejectedData) {
201 | return InkWell(
202 | child: Row(
203 | children: [
204 | Container(
205 | alignment: Alignment.center,
206 | padding: const EdgeInsetsDirectional.only(start: 12, end: 4),
207 | child: childOverride ?? Text(path.integralParts.last),
208 | ),
209 | const Icon(Icons.chevron_right, size: 16),
210 | ],
211 | ),
212 | onTap: () => onTap?.call(path.toPath()),
213 | );
214 | },
215 | ),
216 | );
217 | }
218 | }
219 |
220 | class _LoadingIndicator extends StatefulWidget {
221 | final double? progress;
222 | final Widget child;
223 |
224 | const _LoadingIndicator({
225 | required this.progress,
226 | required this.child,
227 | });
228 |
229 | @override
230 | _LoadingIndicatorState createState() => _LoadingIndicatorState();
231 | }
232 |
233 | class _LoadingIndicatorState extends State<_LoadingIndicator>
234 | with TickerProviderStateMixin {
235 | late AnimationController fadeController;
236 | late AnimationController progressController;
237 |
238 | @override
239 | void initState() {
240 | super.initState();
241 | fadeController = AnimationController(
242 | vsync: this,
243 | duration: const Duration(milliseconds: 250),
244 | value: widget.progress != null ? 1 : 0,
245 | );
246 | progressController = AnimationController(
247 | vsync: this,
248 | duration: const Duration(milliseconds: 150),
249 | value: widget.progress,
250 | );
251 | }
252 |
253 | @override
254 | void didUpdateWidget(covariant _LoadingIndicator old) {
255 | super.didUpdateWidget(old);
256 |
257 | _updateController(old);
258 | }
259 |
260 | Future _updateController(_LoadingIndicator old) async {
261 | if (widget.progress != old.progress) {
262 | if (widget.progress != null && old.progress == null) {
263 | fadeController.forward();
264 | progressController.animateTo(widget.progress!);
265 | } else if (widget.progress == null && old.progress != null) {
266 | await fadeController.reverse();
267 | progressController.value = 0;
268 | } else if (widget.progress != null && old.progress != null) {
269 | if (widget.progress! > old.progress!) {
270 | progressController.animateTo(widget.progress!);
271 | } else if (widget.progress! < old.progress!) {
272 | progressController.animateBack(widget.progress!);
273 | }
274 | }
275 | }
276 | }
277 |
278 | @override
279 | Widget build(BuildContext context) {
280 | return AnimatedBuilder(
281 | animation: Listenable.merge([progressController, fadeController]),
282 | builder: (context, child) {
283 | return CustomPaint(
284 | painter: _LoadingIndicatorPainter(
285 | progress: progressController.value,
286 | opacity: fadeController.value,
287 | color: Theme.of(context).colorScheme.primary,
288 | ),
289 | child: child,
290 | );
291 | },
292 | child: widget.child,
293 | );
294 | }
295 | }
296 |
297 | class _LoadingIndicatorPainter extends CustomPainter {
298 | final double progress;
299 | final double opacity;
300 | final Color color;
301 |
302 | const _LoadingIndicatorPainter({
303 | required this.progress,
304 | required this.opacity,
305 | required this.color,
306 | });
307 |
308 | @override
309 | void paint(Canvas canvas, Size size) {
310 | final Rect baseRect = Offset.zero & size;
311 | final Rect drawingRect = Offset.zero &
312 | Size(
313 | size.width * progress,
314 | size.height,
315 | );
316 |
317 | canvas.drawRect(
318 | baseRect,
319 | Paint()..color = color.withOpacity(opacity * 0.2),
320 | );
321 |
322 | canvas.drawRect(
323 | drawingRect,
324 | Paint()..color = color.withOpacity(opacity * 0.6),
325 | );
326 | }
327 |
328 | @override
329 | bool shouldRepaint(covariant _LoadingIndicatorPainter old) {
330 | return progress != old.progress ||
331 | opacity != old.opacity ||
332 | color.value != old.color.value;
333 | }
334 | }
335 |
--------------------------------------------------------------------------------
/lib/widgets/context_menu.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class ContextMenu extends StatefulWidget {
4 | final List entries;
5 | final Widget child;
6 | final bool openOnLongPress;
7 | final bool openOnSecondaryPress;
8 |
9 | const ContextMenu({
10 | required this.entries,
11 | required this.child,
12 | this.openOnLongPress = true,
13 | this.openOnSecondaryPress = true,
14 | super.key,
15 | });
16 |
17 | @override
18 | State createState() => _ContextMenuState();
19 | }
20 |
21 | class _ContextMenuState extends State {
22 | late Offset lastPosition;
23 |
24 | @override
25 | Widget build(BuildContext context) {
26 | return MenuAnchor(
27 | menuChildren: widget.entries.map((e) => e.buildWrapper(context)).toList(),
28 | builder: (context, controller, child) {
29 | return GestureDetector(
30 | onSecondaryTapUp: (details) =>
31 | controller.open(position: details.localPosition),
32 | onLongPressDown: (details) => lastPosition = details.localPosition,
33 | onLongPress: () => controller.open(position: lastPosition),
34 | child: child,
35 | );
36 | },
37 | child: widget.child,
38 | );
39 | }
40 | }
41 |
42 | class _EnabledBuilder extends StatelessWidget {
43 | final bool enabled;
44 | final Widget child;
45 |
46 | const _EnabledBuilder({
47 | required this.enabled,
48 | required this.child,
49 | });
50 |
51 | @override
52 | Widget build(BuildContext context) {
53 | return IgnorePointer(
54 | ignoring: !enabled,
55 | child: Opacity(
56 | opacity: enabled ? 1 : 0.4,
57 | child: child,
58 | ),
59 | );
60 | }
61 | }
62 |
63 | abstract class BaseContextMenuItem {
64 | final Widget child;
65 | final Widget? leading;
66 | final Widget? trailing;
67 | final bool enabled;
68 |
69 | const BaseContextMenuItem({
70 | required this.child,
71 | this.enabled = true,
72 | this.leading,
73 | this.trailing,
74 | });
75 |
76 | Widget buildWrapper(BuildContext context) =>
77 | _EnabledBuilder(enabled: enabled, child: build(context));
78 |
79 | Widget build(BuildContext context);
80 | Widget? buildLeading(BuildContext context) => leading;
81 | Widget? buildTrailing(BuildContext context) => trailing;
82 | }
83 |
84 | class SubmenuMenuItem extends BaseContextMenuItem {
85 | final List menuChildren;
86 |
87 | const SubmenuMenuItem({
88 | required super.child,
89 | required this.menuChildren,
90 | super.leading,
91 | super.enabled,
92 | }) : super(trailing: null);
93 |
94 | @override
95 | Widget? buildTrailing(BuildContext context) {
96 | return const Icon(Icons.chevron_right, size: 16);
97 | }
98 |
99 | @override
100 | Widget build(BuildContext context) {
101 | return SubmenuButton(
102 | menuChildren: menuChildren.map((e) => e.buildWrapper(context)).toList(),
103 | leadingIcon: buildLeading(context),
104 | trailingIcon: buildTrailing(context),
105 | style: const ButtonStyle(
106 | padding: MaterialStatePropertyAll(
107 | EdgeInsets.symmetric(horizontal: 16),
108 | ),
109 | ),
110 | child: child,
111 | );
112 | }
113 | }
114 |
115 | class ContextMenuItem extends BaseContextMenuItem {
116 | final VoidCallback? onTap;
117 | final MenuSerializableShortcut? shortcut;
118 |
119 | const ContextMenuItem({
120 | required super.child,
121 | this.onTap,
122 | super.leading,
123 | super.trailing,
124 | this.shortcut,
125 | super.enabled,
126 | });
127 |
128 | @override
129 | Widget build(BuildContext context) {
130 | final Widget? leading = buildLeading(context);
131 |
132 | return MenuItemButton(
133 | leadingIcon: leading != null
134 | ? IconTheme.merge(
135 | data: Theme.of(context).iconTheme.copyWith(size: 16),
136 | child: leading,
137 | )
138 | : null,
139 | trailingIcon: buildTrailing(context),
140 | onPressed: onTap,
141 | shortcut: shortcut,
142 | style: const ButtonStyle(
143 | padding: MaterialStatePropertyAll(
144 | EdgeInsets.symmetric(horizontal: 16),
145 | ),
146 | ),
147 | child: child,
148 | );
149 | }
150 | }
151 |
152 | class RadioMenuItem extends ContextMenuItem {
153 | final T value;
154 | final T? groupValue;
155 | final ValueChanged? onChanged;
156 | final bool toggleable;
157 |
158 | const RadioMenuItem({
159 | required this.value,
160 | required this.groupValue,
161 | this.onChanged,
162 | this.toggleable = false,
163 | required super.child,
164 | super.trailing,
165 | super.shortcut,
166 | super.enabled,
167 | }) : super(leading: null, onTap: null);
168 |
169 | @override
170 | VoidCallback? get onTap => onChanged == null
171 | ? null
172 | : () {
173 | if (toggleable && groupValue == value) {
174 | onChanged!.call(null);
175 | return;
176 | }
177 | onChanged!.call(value);
178 | };
179 |
180 | @override
181 | Widget? buildTrailing(BuildContext context) {
182 | return ExcludeFocus(
183 | child: IgnorePointer(
184 | child: ConstrainedBox(
185 | constraints: const BoxConstraints(
186 | maxHeight: Checkbox.width,
187 | maxWidth: Checkbox.width,
188 | ),
189 | child: Radio(
190 | groupValue: groupValue,
191 | value: value,
192 | onChanged: onChanged,
193 | toggleable: toggleable,
194 | ),
195 | ),
196 | ),
197 | );
198 | }
199 | }
200 |
201 | class CheckboxMenuItem extends ContextMenuItem {
202 | final bool? value;
203 | final ValueChanged? onChanged;
204 | final bool tristate;
205 |
206 | const CheckboxMenuItem({
207 | required this.value,
208 | this.onChanged,
209 | this.tristate = false,
210 | required super.child,
211 | super.trailing,
212 | super.shortcut,
213 | super.enabled,
214 | }) : super(leading: null, onTap: null);
215 |
216 | @override
217 | VoidCallback? get onTap => onChanged == null
218 | ? null
219 | : () {
220 | switch (value) {
221 | case false:
222 | onChanged!.call(true);
223 | break;
224 | case true:
225 | onChanged!.call(tristate ? null : false);
226 | break;
227 | case null:
228 | onChanged!.call(false);
229 | break;
230 | }
231 | };
232 |
233 | @override
234 | Widget? buildTrailing(BuildContext context) {
235 | return ExcludeFocus(
236 | child: IgnorePointer(
237 | child: ConstrainedBox(
238 | constraints: const BoxConstraints(
239 | maxHeight: Checkbox.width,
240 | maxWidth: Checkbox.width,
241 | ),
242 | child: Checkbox(
243 | value: value,
244 | onChanged: onChanged,
245 | tristate: tristate,
246 | ),
247 | ),
248 | ),
249 | );
250 | }
251 | }
252 |
253 | class ContextMenuDivider extends BaseContextMenuItem {
254 | const ContextMenuDivider() : super(child: const SizedBox());
255 |
256 | @override
257 | Widget build(BuildContext context) => const Divider();
258 | }
259 |
--------------------------------------------------------------------------------
/lib/widgets/double_scrollbars.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class DoubleScrollbars extends StatelessWidget {
4 | final ScrollController horizontalController;
5 | final ScrollController verticalController;
6 | final Widget child;
7 |
8 | const DoubleScrollbars({
9 | required this.horizontalController,
10 | required this.verticalController,
11 | required this.child,
12 | super.key,
13 | });
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | return SizedBox.expand(
18 | child: ScrollNotificationIsolater(
19 | child: MediaQuery(
20 | data: MediaQueryData(
21 | padding: const EdgeInsetsDirectional.only(bottom: 12)
22 | .resolve(Directionality.of(context)),
23 | ),
24 | child: Scrollbar(
25 | controller: verticalController,
26 | child: _ScrollReceiver(
27 | direction: Axis.vertical,
28 | child: ScrollNotificationIsolater(
29 | child: MediaQuery(
30 | data: MediaQueryData(
31 | padding: const EdgeInsetsDirectional.only(end: 12)
32 | .resolve(Directionality.of(context)),
33 | ),
34 | child: Scrollbar(
35 | controller: horizontalController,
36 | child: _ScrollReceiver(
37 | direction: Axis.horizontal,
38 | child: child,
39 | ),
40 | ),
41 | ),
42 | ),
43 | ),
44 | ),
45 | ),
46 | ),
47 | );
48 | }
49 | }
50 |
51 | class _ScrollReceiver extends StatefulWidget {
52 | final Axis direction;
53 | final Widget child;
54 |
55 | const _ScrollReceiver({
56 | required this.direction,
57 | required this.child,
58 | });
59 |
60 | @override
61 | _ScrollReceiverState createState() => _ScrollReceiverState();
62 | }
63 |
64 | class _ScrollReceiverState extends State<_ScrollReceiver> {
65 | void notify(ScrollNotification notification) {
66 | notification.dispatch(context);
67 | }
68 |
69 | @override
70 | Widget build(BuildContext context) {
71 | switch (widget.direction) {
72 | case Axis.vertical:
73 | return VerticalScrollReceiver._(state: this, child: widget.child);
74 | case Axis.horizontal:
75 | return HorizontalScrollReceiver._(state: this, child: widget.child);
76 | }
77 | }
78 | }
79 |
80 | class _ScrollReceiverInheritedWidget extends InheritedWidget {
81 | final _ScrollReceiverState state;
82 |
83 | const _ScrollReceiverInheritedWidget({
84 | required this.state,
85 | required super.child,
86 | });
87 |
88 | @override
89 | bool updateShouldNotify(covariant InheritedWidget oldWidget) {
90 | return false;
91 | }
92 | }
93 |
94 | class HorizontalScrollReceiver extends _ScrollReceiverInheritedWidget {
95 | const HorizontalScrollReceiver._({
96 | required super.state,
97 | required super.child,
98 | });
99 |
100 | static _ScrollReceiverState of(BuildContext context) {
101 | return context
102 | .dependOnInheritedWidgetOfExactType()!
103 | .state;
104 | }
105 | }
106 |
107 | class VerticalScrollReceiver extends _ScrollReceiverInheritedWidget {
108 | const VerticalScrollReceiver._({
109 | required super.state,
110 | required super.child,
111 | });
112 |
113 | static _ScrollReceiverState of(BuildContext context) {
114 | return context
115 | .dependOnInheritedWidgetOfExactType()!
116 | .state;
117 | }
118 | }
119 |
120 | class ScrollProxy extends StatelessWidget {
121 | final Axis direction;
122 | final Widget child;
123 |
124 | const ScrollProxy({
125 | required this.direction,
126 | required this.child,
127 | super.key,
128 | });
129 |
130 | @override
131 | Widget build(BuildContext context) {
132 | return NotificationListener(
133 | onNotification: (notification) {
134 | late final _ScrollReceiverState provider;
135 |
136 | switch (direction) {
137 | case Axis.vertical:
138 | provider = VerticalScrollReceiver.of(context);
139 | break;
140 | case Axis.horizontal:
141 | provider = HorizontalScrollReceiver.of(context);
142 | break;
143 | }
144 |
145 | provider.notify(notification);
146 | return true;
147 | },
148 | child: child,
149 | );
150 | }
151 | }
152 |
153 | class ScrollNotificationIsolater extends StatelessWidget {
154 | final Widget child;
155 |
156 | const ScrollNotificationIsolater({
157 | required this.child,
158 | super.key,
159 | });
160 |
161 | @override
162 | Widget build(BuildContext context) {
163 | return NotificationListener(
164 | onNotification: (notification) => true,
165 | child: child,
166 | );
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/lib/widgets/entity_context_menu.dart:
--------------------------------------------------------------------------------
1 | import 'package:files/widgets/context_menu.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter/services.dart';
4 |
5 | class EntityContextMenu extends StatelessWidget {
6 | final Widget child;
7 | final VoidCallback? onOpen;
8 | final VoidCallback? onOpenWith;
9 | final VoidCallback? onCopy;
10 | final VoidCallback? onCut;
11 | final VoidCallback? onPaste;
12 |
13 | const EntityContextMenu({
14 | required this.child,
15 | this.onOpen,
16 | this.onOpenWith,
17 | this.onCopy,
18 | this.onCut,
19 | this.onPaste,
20 | super.key,
21 | });
22 |
23 | @override
24 | Widget build(BuildContext context) {
25 | return ContextMenu(
26 | entries: [
27 | ContextMenuItem(
28 | child: const Text("Open"),
29 | onTap: onOpen,
30 | shortcut: const SingleActivator(LogicalKeyboardKey.enter),
31 | ),
32 | ContextMenuItem(
33 | child: const Text("Open with other application"),
34 | onTap: onOpenWith,
35 | enabled: false,
36 | ),
37 | const ContextMenuDivider(),
38 | ContextMenuItem(
39 | leading: const Icon(Icons.file_copy_outlined),
40 | child: const Text("Copy file"),
41 | onTap: onCopy,
42 | shortcut:
43 | const SingleActivator(LogicalKeyboardKey.keyC, control: true),
44 | ),
45 | ContextMenuItem(
46 | leading: const Icon(Icons.cut_outlined),
47 | child: const Text("Cut file"),
48 | onTap: onCut,
49 | shortcut:
50 | const SingleActivator(LogicalKeyboardKey.keyX, control: true),
51 | ),
52 | ContextMenuItem(
53 | leading: const Icon(Icons.paste_outlined),
54 | child: const Text("Paste file"),
55 | onTap: onPaste,
56 | shortcut:
57 | const SingleActivator(LogicalKeyboardKey.keyV, control: true),
58 | )
59 | ],
60 | child: child,
61 | );
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/lib/widgets/folder_dialog.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class FolderDialog extends StatefulWidget {
4 | const FolderDialog({super.key});
5 |
6 | @override
7 | State createState() => _FolderDialogState();
8 | }
9 |
10 | class _FolderDialogState extends State {
11 | final TextEditingController controller = TextEditingController();
12 | final RegExp folderValidator = RegExp(
13 | r'^[^\s^\x00-\x1f\\?*:"";<>|\/][^\x00-\x1f\\?*:"";<>|\/]*[^\s^\x00-\x1f\\?*:"";<>|\/.]+$',
14 | );
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return AlertDialog(
19 | title: const Text("New Folder"),
20 | content: TextField(
21 | autofocus: true,
22 | decoration: const InputDecoration(
23 | hintText: "Folder name",
24 | ),
25 | controller: controller,
26 | onSubmitted: (value) {
27 | Navigator.pop(context, value);
28 | },
29 | ),
30 | actions: [
31 | TextButton(
32 | child: const Text("Cancel"),
33 | onPressed: () {
34 | Navigator.pop(context);
35 | },
36 | ),
37 | ValueListenableBuilder(
38 | valueListenable: controller,
39 | builder: (context, value, __) => TextButton(
40 | onPressed:
41 | value.text.isNotEmpty && folderValidator.hasMatch(value.text)
42 | ? () => Navigator.of(context).pop(controller.text)
43 | : null,
44 | child: const Text("Create"),
45 | ),
46 | ),
47 | ],
48 | );
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/lib/widgets/grid.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:files/backend/entity_info.dart';
4 | import 'package:files/backend/utils.dart';
5 | import 'package:files/backend/workspace.dart';
6 | import 'package:files/widgets/entity_context_menu.dart';
7 | import 'package:files/widgets/timed_inkwell.dart';
8 | import 'package:flutter/material.dart';
9 |
10 | typedef EntityCallback = void Function(EntityInfo entity);
11 | typedef DropAcceptCallback = void Function(String path);
12 |
13 | class FilesGrid extends StatefulWidget {
14 | final List entities;
15 | final EntityCallback? onEntityTap;
16 | final EntityCallback? onEntityDoubleTap;
17 | final EntityCallback? onEntityLongTap;
18 | final EntityCallback? onEntitySecondaryTap;
19 | final ValueChanged? onSizeChange;
20 | final DropAcceptCallback? onDropAccept;
21 | final double size;
22 | final ScrollController? controller;
23 |
24 | const FilesGrid({
25 | required this.entities,
26 | this.onEntityTap,
27 | this.onEntityDoubleTap,
28 | this.onEntityLongTap,
29 | this.onEntitySecondaryTap,
30 | this.onDropAccept,
31 | this.onSizeChange,
32 | this.size = 96,
33 | this.controller,
34 | super.key,
35 | });
36 |
37 | @override
38 | State createState() => _FilesGridState();
39 | }
40 |
41 | class _FilesGridState extends State {
42 | final ScrollController _internalScrollController = ScrollController();
43 | ScrollController get scrollController =>
44 | widget.controller ?? _internalScrollController;
45 |
46 | @override
47 | Widget build(BuildContext context) {
48 | final WorkspaceController controller = WorkspaceController.of(context);
49 |
50 | return GestureDetector(
51 | onTap: controller.clearSelectedItems,
52 | child: Scrollbar(
53 | controller: scrollController,
54 | child: GridView.builder(
55 | gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
56 | maxCrossAxisExtent: widget.size,
57 | mainAxisExtent: widget.size,
58 | mainAxisSpacing: 16.0,
59 | crossAxisSpacing: 16.0,
60 | ),
61 | padding: const EdgeInsets.all(16),
62 | itemCount: widget.entities.length,
63 | controller: scrollController,
64 | itemBuilder: (context, index) {
65 | final EntityInfo entityInfo = widget.entities[index];
66 |
67 | return Draggable(
68 | data: entityInfo.entity,
69 | dragAnchorStrategy: (_, __, ___) => const Offset(32, 32),
70 | feedback: DecoratedBox(
71 | decoration: BoxDecoration(
72 | color:
73 | Theme.of(context).colorScheme.onSurface.withOpacity(0.2),
74 | borderRadius: BorderRadius.circular(4),
75 | ),
76 | child: Center(
77 | child: Cell(
78 | name: Utils.getEntityName(entityInfo.entity.path),
79 | icon: entityInfo.isDirectory
80 | ? Utils.iconForFolder(entityInfo.path)
81 | : Utils.iconForPath(entityInfo.path),
82 | iconColor: entityInfo.isDirectory
83 | ? Theme.of(context).colorScheme.primary
84 | : null,
85 | ),
86 | ),
87 | ),
88 | child: FileCell(
89 | entity: entityInfo,
90 | selected: controller.selectedItems.contains(entityInfo),
91 | onTap: widget.onEntityTap,
92 | onDoubleTap: widget.onEntityDoubleTap,
93 | onLongTap: widget.onEntityLongTap,
94 | onSecondaryTap: widget.onEntitySecondaryTap,
95 | onDropAccept: widget.onDropAccept,
96 | ),
97 | );
98 | },
99 | ),
100 | ),
101 | );
102 | }
103 | }
104 |
105 | class FileCell extends StatelessWidget {
106 | final EntityInfo entity;
107 | final bool selected;
108 | final EntityCallback? onTap;
109 | final EntityCallback? onDoubleTap;
110 | final EntityCallback? onLongTap;
111 | final EntityCallback? onSecondaryTap;
112 | final DropAcceptCallback? onDropAccept;
113 |
114 | const FileCell({
115 | required this.entity,
116 | this.selected = false,
117 | this.onTap,
118 | this.onDoubleTap,
119 | this.onLongTap,
120 | this.onSecondaryTap,
121 | this.onDropAccept,
122 | super.key,
123 | });
124 |
125 | @override
126 | Widget build(BuildContext context) {
127 | return DragTarget(
128 | onWillAccept: (data) {
129 | if (!entity.isDirectory) return false;
130 |
131 | if (data!.path == entity.path) return false;
132 |
133 | return true;
134 | },
135 | onAccept: (_) => onDropAccept?.call(entity.path),
136 | builder: (context, _, __) => Container(
137 | clipBehavior: Clip.antiAlias,
138 | decoration: BoxDecoration(
139 | color: selected
140 | ? Theme.of(context).colorScheme.primary.withOpacity(0.2)
141 | : Colors.transparent,
142 | borderRadius: BorderRadius.circular(4),
143 | ),
144 | child: TimedInkwell(
145 | onTap: () => onTap?.call(entity),
146 | onDoubleTap: () {
147 | onTap?.call(entity);
148 | onDoubleTap?.call(entity);
149 | },
150 | onLongPress: () => onLongTap?.call(entity),
151 | child: EntityContextMenu(
152 | onOpen: () {
153 | onTap?.call(entity);
154 | onDoubleTap?.call(entity);
155 | },
156 | child: Center(
157 | child: Cell(
158 | name: Utils.getEntityName(entity.path),
159 | icon: entity.isDirectory
160 | ? Utils.iconForFolder(entity.path)
161 | : Utils.iconForPath(entity.path),
162 | iconColor: entity.isDirectory
163 | ? Theme.of(context).colorScheme.primary
164 | : null,
165 | ),
166 | ),
167 | ),
168 | ),
169 | ),
170 | );
171 | }
172 | }
173 |
174 | class Cell extends StatelessWidget {
175 | final String name;
176 | final IconData icon;
177 | final Color? iconColor;
178 |
179 | const Cell({
180 | required this.name,
181 | required this.icon,
182 | this.iconColor,
183 | super.key,
184 | });
185 |
186 | @override
187 | Widget build(BuildContext context) {
188 | return Column(
189 | mainAxisAlignment: MainAxisAlignment.center,
190 | children: [
191 | const SizedBox(height: 8),
192 | Expanded(
193 | child: _ConstrainedIcon(
194 | child: Icon(
195 | icon,
196 | color: iconColor,
197 | ),
198 | ),
199 | ),
200 | const SizedBox(height: 8),
201 | DefaultTextStyle(
202 | style: const TextStyle(fontSize: 14),
203 | overflow: TextOverflow.ellipsis,
204 | maxLines: 1,
205 | textAlign: TextAlign.center,
206 | child: Text(name),
207 | ),
208 | const SizedBox(height: 8),
209 | ],
210 | );
211 | }
212 | }
213 |
214 | class _ConstrainedIcon extends StatelessWidget {
215 | final Widget child;
216 |
217 | const _ConstrainedIcon({required this.child});
218 |
219 | @override
220 | Widget build(BuildContext context) {
221 | return LayoutBuilder(
222 | builder: (context, constraints) {
223 | return IconTheme(
224 | data: Theme.of(context)
225 | .iconTheme
226 | .copyWith(size: constraints.biggest.shortestSide),
227 | child: child,
228 | );
229 | },
230 | );
231 | }
232 | }
233 |
--------------------------------------------------------------------------------
/lib/widgets/side_pane.dart:
--------------------------------------------------------------------------------
1 | import 'package:files/backend/folder_provider.dart';
2 | import 'package:files/backend/workspace.dart';
3 | import 'package:files/widgets/context_menu.dart';
4 | import 'package:flutter/material.dart';
5 |
6 | typedef NewTabCallback = void Function(String);
7 |
8 | class SidePane extends StatefulWidget {
9 | final List destinations;
10 | final WorkspaceController workspace;
11 | final NewTabCallback onNewTab;
12 |
13 | const SidePane({
14 | required this.destinations,
15 | required this.workspace,
16 | required this.onNewTab,
17 | super.key,
18 | });
19 |
20 | @override
21 | _SidePaneState createState() => _SidePaneState();
22 | }
23 |
24 | class _SidePaneState extends State {
25 | @override
26 | void initState() {
27 | super.initState();
28 | widget.workspace.addListener(updateOnDirChange);
29 | }
30 |
31 | @override
32 | void didUpdateWidget(covariant SidePane old) {
33 | super.didUpdateWidget(old);
34 | if (widget.workspace != old.workspace) {
35 | old.workspace.removeListener(updateOnDirChange);
36 | widget.workspace.addListener(updateOnDirChange);
37 | }
38 | }
39 |
40 | @override
41 | void dispose() {
42 | widget.workspace.removeListener(updateOnDirChange);
43 | super.dispose();
44 | }
45 |
46 | void updateOnDirChange() {
47 | if (mounted) setState(() {});
48 | }
49 |
50 | @override
51 | Widget build(BuildContext context) {
52 | return SizedBox(
53 | width: 304,
54 | child: Material(
55 | color: Theme.of(context).colorScheme.surface,
56 | child: ListView.builder(
57 | padding: const EdgeInsets.only(top: 56),
58 | itemCount: widget.destinations.length,
59 | itemBuilder: (context, index) => ContextMenu(
60 | entries: [
61 | ContextMenuItem(
62 | child: const Text("Open"),
63 | onTap: () => widget.workspace
64 | .changeCurrentDir(widget.destinations[index].path),
65 | ),
66 | ContextMenuItem(
67 | child: const Text("Open in new tab"),
68 | onTap: () => widget.onNewTab(widget.destinations[index].path),
69 | ),
70 | ContextMenuItem(
71 | child: const Text("Open in new window"),
72 | onTap: () {},
73 | enabled: false,
74 | ),
75 | ],
76 | child: ListTile(
77 | dense: true,
78 | leading: Icon(widget.destinations[index].icon),
79 | selected: widget.workspace.currentDir ==
80 | widget.destinations[index].path,
81 | selectedTileColor:
82 | Theme.of(context).colorScheme.primary.withOpacity(0.1),
83 | title: Text(
84 | widget.destinations[index].label,
85 | ),
86 | onTap: () => widget.workspace
87 | .changeCurrentDir(widget.destinations[index].path),
88 | ),
89 | ),
90 | ),
91 | ),
92 | );
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/lib/widgets/tab_strip.dart:
--------------------------------------------------------------------------------
1 | import 'package:files/backend/utils.dart';
2 | import 'package:files/backend/workspace.dart';
3 | import 'package:files/widgets/context_menu.dart';
4 | import 'package:flutter/material.dart';
5 |
6 | class TabStrip extends StatelessWidget {
7 | final List tabs;
8 | final int selectedTab;
9 | final bool allowClosing;
10 | final ValueChanged? onTabChanged;
11 | final ValueChanged? onTabClosed;
12 | final VoidCallback? onNewTab;
13 |
14 | const TabStrip({
15 | required this.tabs,
16 | required this.selectedTab,
17 | this.allowClosing = true,
18 | this.onTabChanged,
19 | this.onTabClosed,
20 | this.onNewTab,
21 | super.key,
22 | });
23 |
24 | @override
25 | Widget build(BuildContext context) {
26 | return SizedBox.expand(
27 | child: Row(
28 | children: [
29 | Expanded(
30 | child: ListView.separated(
31 | itemBuilder: (context, index) => ContextMenu(
32 | openOnLongPress: false,
33 | entries: [
34 | ContextMenuItem(
35 | child: const Text("Create new tab"),
36 | onTap: () => onNewTab?.call(),
37 | ),
38 | ContextMenuItem(
39 | child: const Text("Close tab"),
40 | onTap: () => onTabClosed?.call(index),
41 | enabled: allowClosing,
42 | ),
43 | ],
44 | child: _Tab(
45 | tab: tabs[index],
46 | selected: selectedTab == index,
47 | onTap: () => onTabChanged?.call(index),
48 | onClosed: () => onTabClosed?.call(index),
49 | allowClosing: allowClosing,
50 | ),
51 | ),
52 | scrollDirection: Axis.horizontal,
53 | separatorBuilder: (context, index) => const SizedBox(width: 8),
54 | itemCount: tabs.length,
55 | padding: const EdgeInsets.all(8),
56 | ),
57 | ),
58 | IconButton(
59 | onPressed: onNewTab,
60 | icon: const Icon(Icons.add),
61 | ),
62 | ],
63 | ),
64 | );
65 | }
66 | }
67 |
68 | class _Tab extends StatefulWidget {
69 | final WorkspaceController tab;
70 | final bool selected;
71 | final VoidCallback? onTap;
72 | final VoidCallback? onClosed;
73 | final bool allowClosing;
74 |
75 | const _Tab({
76 | required this.tab,
77 | required this.selected,
78 | this.onTap,
79 | this.onClosed,
80 | this.allowClosing = true,
81 | });
82 |
83 | @override
84 | State<_Tab> createState() => _TabState();
85 | }
86 |
87 | class _TabState extends State<_Tab> {
88 | @override
89 | void initState() {
90 | super.initState();
91 | widget.tab.addListener(updateOnDirChange);
92 | }
93 |
94 | @override
95 | void dispose() {
96 | widget.tab.removeListener(updateOnDirChange);
97 | super.dispose();
98 | }
99 |
100 | void updateOnDirChange() {
101 | if (mounted) setState(() {});
102 | }
103 |
104 | @override
105 | Widget build(BuildContext context) {
106 | return SizedBox(
107 | width: 240,
108 | height: double.infinity,
109 | child: Material(
110 | color: widget.selected
111 | ? Theme.of(context).colorScheme.surface
112 | : Theme.of(context).colorScheme.background,
113 | shape: RoundedRectangleBorder(
114 | borderRadius: BorderRadius.circular(4),
115 | ),
116 | clipBehavior: Clip.antiAlias,
117 | child: InkWell(
118 | onTap: widget.onTap,
119 | child: Padding(
120 | padding: const EdgeInsets.symmetric(horizontal: 8.0),
121 | child: Row(
122 | children: [
123 | Icon(Utils.iconForFolder(widget.tab.currentDir), size: 16),
124 | const SizedBox(width: 8),
125 | Expanded(
126 | child: Text(
127 | Utils.getEntityName(widget.tab.currentDir),
128 | overflow: TextOverflow.ellipsis,
129 | ),
130 | ),
131 | AnimatedOpacity(
132 | opacity: widget.allowClosing ? 1 : 0,
133 | duration: const Duration(milliseconds: 200),
134 | child: IconButton(
135 | onPressed: widget.allowClosing ? widget.onClosed : null,
136 | icon: const Icon(Icons.close),
137 | iconSize: 16,
138 | splashRadius: 16,
139 | padding: EdgeInsets.zero,
140 | constraints: BoxConstraints.tight(const Size.square(16)),
141 | ),
142 | ),
143 | ],
144 | ),
145 | ),
146 | ),
147 | ),
148 | );
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/lib/widgets/timed_inkwell.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/material.dart';
4 |
5 | class TimedInkwell extends StatefulWidget {
6 | final Widget? child;
7 | final VoidCallback? onTap;
8 | final VoidCallback? onDoubleTap;
9 | final VoidCallback? onLongPress;
10 | final Duration tapDelay;
11 |
12 | const TimedInkwell({
13 | this.child,
14 | this.onTap,
15 | this.onDoubleTap,
16 | this.onLongPress,
17 | this.tapDelay = const Duration(milliseconds: 300),
18 | super.key,
19 | });
20 |
21 | @override
22 | State createState() => _TimedInkwellState();
23 | }
24 |
25 | class _TimedInkwellState extends State {
26 | Timer? _tapTimer;
27 | bool _awaitingDoubleTap = false;
28 |
29 | @override
30 | Widget build(BuildContext context) {
31 | return InkWell(
32 | onTap: () {
33 | widget.onTap?.call();
34 | if (_awaitingDoubleTap) {
35 | widget.onDoubleTap?.call();
36 | _awaitingDoubleTap = false;
37 | _tapTimer?.cancel();
38 | _tapTimer = null;
39 | } else {
40 | _awaitingDoubleTap = true;
41 | _tapTimer = Timer(widget.tapDelay, () => _awaitingDoubleTap = false);
42 | }
43 | },
44 | onLongPress: widget.onLongPress,
45 | child: widget.child,
46 | );
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 | project(runner LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "files")
5 | set(APPLICATION_ID "com.example.files")
6 |
7 | cmake_policy(SET CMP0063 NEW)
8 |
9 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
10 |
11 | # Configure build options.
12 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
13 | set(CMAKE_BUILD_TYPE "Debug" CACHE
14 | STRING "Flutter build mode" FORCE)
15 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
16 | "Debug" "Profile" "Release")
17 | endif()
18 |
19 | # Compilation settings that should be applied to most targets.
20 | function(APPLY_STANDARD_SETTINGS TARGET)
21 | target_compile_features(${TARGET} PUBLIC cxx_std_14)
22 | target_compile_options(${TARGET} PRIVATE -Wall -Werror)
23 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>")
24 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>")
25 | endfunction()
26 |
27 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
28 |
29 | # Flutter library and tool build rules.
30 | add_subdirectory(${FLUTTER_MANAGED_DIR})
31 |
32 | # System-level dependencies.
33 | find_package(PkgConfig REQUIRED)
34 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
35 |
36 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
37 |
38 | # Application build
39 | add_executable(${BINARY_NAME}
40 | "main.cc"
41 | "my_application.cc"
42 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
43 | )
44 | apply_standard_settings(${BINARY_NAME})
45 | target_link_libraries(${BINARY_NAME} PRIVATE flutter)
46 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
47 | add_dependencies(${BINARY_NAME} flutter_assemble)
48 | # Only the install-generated bundle's copy of the executable will launch
49 | # correctly, since the resources must in the right relative locations. To avoid
50 | # people trying to run the unbundled copy, put it in a subdirectory instead of
51 | # the default top-level location.
52 | set_target_properties(${BINARY_NAME}
53 | PROPERTIES
54 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
55 | )
56 |
57 | # Generated plugin build rules, which manage building the plugins and adding
58 | # them to the application.
59 | include(flutter/generated_plugins.cmake)
60 |
61 |
62 | # === Installation ===
63 | # By default, "installing" just makes a relocatable bundle in the build
64 | # directory.
65 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
66 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
67 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
68 | endif()
69 |
70 | # Start with a clean build bundle directory every time.
71 | install(CODE "
72 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
73 | " COMPONENT Runtime)
74 |
75 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
76 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
77 |
78 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
79 | COMPONENT Runtime)
80 |
81 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
82 | COMPONENT Runtime)
83 |
84 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
85 | COMPONENT Runtime)
86 |
87 | if(PLUGIN_BUNDLED_LIBRARIES)
88 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
89 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
90 | COMPONENT Runtime)
91 | endif()
92 |
93 | # Fully re-copy the assets directory on each build to avoid having stale files
94 | # from a previous install.
95 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
96 | install(CODE "
97 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
98 | " COMPONENT Runtime)
99 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
100 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
101 |
102 | # Install the AOT library on non-Debug builds only.
103 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
104 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
105 | COMPONENT Runtime)
106 | endif()
107 |
--------------------------------------------------------------------------------
/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.10)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 |
11 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
12 | # which isn't available in 3.10.
13 | function(list_prepend LIST_NAME PREFIX)
14 | set(NEW_LIST "")
15 | foreach(element ${${LIST_NAME}})
16 | list(APPEND NEW_LIST "${PREFIX}${element}")
17 | endforeach(element)
18 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
19 | endfunction()
20 |
21 | # === Flutter Library ===
22 | # System-level dependencies.
23 | find_package(PkgConfig REQUIRED)
24 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
25 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
26 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
27 | pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid)
28 | pkg_check_modules(LZMA REQUIRED IMPORTED_TARGET liblzma)
29 |
30 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
31 |
32 | # Published to parent scope for install step.
33 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
34 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
35 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
36 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
37 |
38 | list(APPEND FLUTTER_LIBRARY_HEADERS
39 | "fl_basic_message_channel.h"
40 | "fl_binary_codec.h"
41 | "fl_binary_messenger.h"
42 | "fl_dart_project.h"
43 | "fl_engine.h"
44 | "fl_json_message_codec.h"
45 | "fl_json_method_codec.h"
46 | "fl_message_codec.h"
47 | "fl_method_call.h"
48 | "fl_method_channel.h"
49 | "fl_method_codec.h"
50 | "fl_method_response.h"
51 | "fl_plugin_registrar.h"
52 | "fl_plugin_registry.h"
53 | "fl_standard_message_codec.h"
54 | "fl_standard_method_codec.h"
55 | "fl_string_codec.h"
56 | "fl_value.h"
57 | "fl_view.h"
58 | "flutter_linux.h"
59 | )
60 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
61 | add_library(flutter INTERFACE)
62 | target_include_directories(flutter INTERFACE
63 | "${EPHEMERAL_DIR}"
64 | )
65 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
66 | target_link_libraries(flutter INTERFACE
67 | PkgConfig::GTK
68 | PkgConfig::GLIB
69 | PkgConfig::GIO
70 | PkgConfig::BLKID
71 | PkgConfig::LZMA
72 | )
73 | add_dependencies(flutter flutter_assemble)
74 |
75 | # === Flutter tool backend ===
76 | # _phony_ is a non-existent file to force this command to run every time,
77 | # since currently there's no way to get a full input/output list from the
78 | # flutter tool.
79 | add_custom_command(
80 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
81 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
82 | COMMAND ${CMAKE_COMMAND} -E env
83 | ${FLUTTER_TOOL_ENVIRONMENT}
84 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
85 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
86 | VERBATIM
87 | )
88 | add_custom_target(flutter_assemble DEPENDS
89 | "${FLUTTER_LIBRARY}"
90 | ${FLUTTER_LIBRARY_HEADERS}
91 | )
92 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 |
12 | void fl_register_plugins(FlPluginRegistry* registry) {
13 | g_autoptr(FlPluginRegistrar) isar_flutter_libs_registrar =
14 | fl_plugin_registry_get_registrar_for_plugin(registry, "IsarFlutterLibsPlugin");
15 | isar_flutter_libs_plugin_register_with_registrar(isar_flutter_libs_registrar);
16 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
17 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
18 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
19 | }
20 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | isar_flutter_libs
7 | url_launcher_linux
8 | )
9 |
10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
11 | )
12 |
13 | set(PLUGIN_BUNDLED_LIBRARIES)
14 |
15 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
20 | endforeach(plugin)
21 |
22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
25 | endforeach(ffi_plugin)
26 |
--------------------------------------------------------------------------------
/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/linux/my_application.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | #include
4 | #ifdef GDK_WINDOWING_X11
5 | #include
6 | #endif
7 |
8 | #include "flutter/generated_plugin_registrant.h"
9 |
10 | struct _MyApplication {
11 | GtkApplication parent_instance;
12 | char** dart_entrypoint_arguments;
13 | };
14 |
15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
16 |
17 | // Implements GApplication::activate.
18 | static void my_application_activate(GApplication* application) {
19 | MyApplication* self = MY_APPLICATION(application);
20 | GtkWindow* window =
21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
22 |
23 | // Use a header bar when running in GNOME as this is the common style used
24 | // by applications and is the setup most users will be using (e.g. Ubuntu
25 | // desktop).
26 | // If running on X and not using GNOME then just use a traditional title bar
27 | // in case the window manager does more exotic layout, e.g. tiling.
28 | // If running on Wayland assume the header bar will work (may need changing
29 | // if future cases occur).
30 | gboolean use_header_bar = TRUE;
31 | #ifdef GDK_WINDOWING_X11
32 | GdkScreen *screen = gtk_window_get_screen(window);
33 | if (GDK_IS_X11_SCREEN(screen)) {
34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
36 | use_header_bar = FALSE;
37 | }
38 | }
39 | #endif
40 | if (use_header_bar) {
41 | GtkHeaderBar *header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
42 | gtk_widget_show(GTK_WIDGET(header_bar));
43 | gtk_header_bar_set_title(header_bar, "files");
44 | gtk_header_bar_set_show_close_button(header_bar, TRUE);
45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
46 | }
47 | else {
48 | gtk_window_set_title(window, "files");
49 | }
50 |
51 | gtk_window_set_default_size(window, 1280, 720);
52 | gtk_widget_show(GTK_WIDGET(window));
53 |
54 | g_autoptr(FlDartProject) project = fl_dart_project_new();
55 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
56 |
57 | FlView* view = fl_view_new(project);
58 | gtk_widget_show(GTK_WIDGET(view));
59 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
60 |
61 | fl_register_plugins(FL_PLUGIN_REGISTRY(view));
62 |
63 | gtk_widget_grab_focus(GTK_WIDGET(view));
64 | }
65 |
66 | // Implements GApplication::local_command_line.
67 | static gboolean my_application_local_command_line(GApplication* application, gchar ***arguments, int *exit_status) {
68 | MyApplication* self = MY_APPLICATION(application);
69 | // Strip out the first argument as it is the binary name.
70 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
71 |
72 | g_autoptr(GError) error = nullptr;
73 | if (!g_application_register(application, nullptr, &error)) {
74 | g_warning("Failed to register: %s", error->message);
75 | *exit_status = 1;
76 | return TRUE;
77 | }
78 |
79 | g_application_activate(application);
80 | *exit_status = 0;
81 |
82 | return TRUE;
83 | }
84 |
85 | // Implements GObject::dispose.
86 | static void my_application_dispose(GObject *object) {
87 | MyApplication* self = MY_APPLICATION(object);
88 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
89 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
90 | }
91 |
92 | static void my_application_class_init(MyApplicationClass* klass) {
93 | G_APPLICATION_CLASS(klass)->activate = my_application_activate;
94 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line;
95 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
96 | }
97 |
98 | static void my_application_init(MyApplication* self) {}
99 |
100 | MyApplication* my_application_new() {
101 | return MY_APPLICATION(g_object_new(my_application_get_type(),
102 | "application-id", APPLICATION_ID,
103 | "flags", G_APPLICATION_NON_UNIQUE,
104 | nullptr));
105 | }
106 |
--------------------------------------------------------------------------------
/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: files
2 | description: dahliaOS Files.
3 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
4 |
5 | version: 1.0.0+1
6 |
7 | environment:
8 | sdk: ">=2.17.0 <3.0.0"
9 |
10 | dependencies:
11 | collection: ^1.16.0
12 |
13 | ffi: ^2.0.1
14 | filesize: ^2.0.1
15 | flutter:
16 | sdk: flutter
17 |
18 | intl: any
19 | isar: ^3.0.2
20 | isar_flutter_libs: ^3.0.2
21 |
22 | material_design_icons_flutter: ^6.0.7096
23 | mime: ^1.0.0
24 |
25 | path: ^1.8.2
26 | path_provider: ^2.0.2
27 | provider: ^6.0.0
28 |
29 | recase: ^4.1.0
30 | ubuntu_service: ^0.2.0
31 | url_launcher: any
32 | windows_path_provider:
33 | git:
34 | url: https://github.com/HrX03/windows_path_provider.git
35 | xdg_directories: ^1.0.0
36 |
37 | dev_dependencies:
38 | build_runner: ^2.3.2
39 | isar_generator: ^3.0.2
40 | lint: ^2.1.1
41 |
42 | flutter:
43 | uses-material-design: true
44 |
--------------------------------------------------------------------------------
/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/web/favicon.png
--------------------------------------------------------------------------------
/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | files
30 |
31 |
32 |
33 |
36 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "files",
3 | "short_name": "files",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(files LANGUAGES CXX)
3 |
4 | set(BINARY_NAME "files")
5 |
6 | cmake_policy(SET CMP0063 NEW)
7 |
8 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
9 |
10 | # Configure build options.
11 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
12 | if(IS_MULTICONFIG)
13 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
14 | CACHE STRING "" FORCE)
15 | else()
16 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
17 | set(CMAKE_BUILD_TYPE "Debug" CACHE
18 | STRING "Flutter build mode" FORCE)
19 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
20 | "Debug" "Profile" "Release")
21 | endif()
22 | endif()
23 |
24 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
25 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
26 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
27 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
28 |
29 | # Use Unicode for all projects.
30 | add_definitions(-DUNICODE -D_UNICODE)
31 |
32 | # Compilation settings that should be applied to most targets.
33 | function(APPLY_STANDARD_SETTINGS TARGET)
34 | target_compile_features(${TARGET} PUBLIC cxx_std_17)
35 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
36 | target_compile_options(${TARGET} PRIVATE /EHsc)
37 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
38 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>")
39 | endfunction()
40 |
41 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
42 |
43 | # Flutter library and tool build rules.
44 | add_subdirectory(${FLUTTER_MANAGED_DIR})
45 |
46 | # Application build
47 | add_subdirectory("runner")
48 |
49 | # Generated plugin build rules, which manage building the plugins and adding
50 | # them to the application.
51 | include(flutter/generated_plugins.cmake)
52 |
53 |
54 | # === Installation ===
55 | # Support files are copied into place next to the executable, so that it can
56 | # run in place. This is done instead of making a separate bundle (as on Linux)
57 | # so that building and running from within Visual Studio will work.
58 | set(BUILD_BUNDLE_DIR "$")
59 | # Make the "install" step default, as it's required to run.
60 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
61 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
62 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
63 | endif()
64 |
65 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
66 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
67 |
68 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
69 | COMPONENT Runtime)
70 |
71 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
72 | COMPONENT Runtime)
73 |
74 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
75 | COMPONENT Runtime)
76 |
77 | if(PLUGIN_BUNDLED_LIBRARIES)
78 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
79 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
80 | COMPONENT Runtime)
81 | endif()
82 |
83 | # Fully re-copy the assets directory on each build to avoid having stale files
84 | # from a previous install.
85 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
86 | install(CODE "
87 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
88 | " COMPONENT Runtime)
89 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
90 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
91 |
92 | # Install the AOT library on non-Debug builds only.
93 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
94 | CONFIGURATIONS Profile;Release
95 | COMPONENT Runtime)
96 |
97 | install(FILES "libs/libisar.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
98 | COMPONENT Runtime)
--------------------------------------------------------------------------------
/windows/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 |
3 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
4 |
5 | # Configuration provided via flutter tool.
6 | include(${EPHEMERAL_DIR}/generated_config.cmake)
7 |
8 | # TODO: Move the rest of this into files in ephemeral. See
9 | # https://github.com/flutter/flutter/issues/57146.
10 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
11 |
12 | # === Flutter Library ===
13 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
14 |
15 | # Published to parent scope for install step.
16 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
17 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
18 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
19 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
20 |
21 | list(APPEND FLUTTER_LIBRARY_HEADERS
22 | "flutter_export.h"
23 | "flutter_windows.h"
24 | "flutter_messenger.h"
25 | "flutter_plugin_registrar.h"
26 | "flutter_texture_registrar.h"
27 | )
28 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
29 | add_library(flutter INTERFACE)
30 | target_include_directories(flutter INTERFACE
31 | "${EPHEMERAL_DIR}"
32 | )
33 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
34 | add_dependencies(flutter flutter_assemble)
35 |
36 | # === Wrapper ===
37 | list(APPEND CPP_WRAPPER_SOURCES_CORE
38 | "core_implementations.cc"
39 | "standard_codec.cc"
40 | )
41 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
42 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
43 | "plugin_registrar.cc"
44 | )
45 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
46 | list(APPEND CPP_WRAPPER_SOURCES_APP
47 | "flutter_engine.cc"
48 | "flutter_view_controller.cc"
49 | )
50 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
51 |
52 | # Wrapper sources needed for a plugin.
53 | add_library(flutter_wrapper_plugin STATIC
54 | ${CPP_WRAPPER_SOURCES_CORE}
55 | ${CPP_WRAPPER_SOURCES_PLUGIN}
56 | )
57 | apply_standard_settings(flutter_wrapper_plugin)
58 | set_target_properties(flutter_wrapper_plugin PROPERTIES
59 | POSITION_INDEPENDENT_CODE ON)
60 | set_target_properties(flutter_wrapper_plugin PROPERTIES
61 | CXX_VISIBILITY_PRESET hidden)
62 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
63 | target_include_directories(flutter_wrapper_plugin PUBLIC
64 | "${WRAPPER_ROOT}/include"
65 | )
66 | add_dependencies(flutter_wrapper_plugin flutter_assemble)
67 |
68 | # Wrapper sources needed for the runner.
69 | add_library(flutter_wrapper_app STATIC
70 | ${CPP_WRAPPER_SOURCES_CORE}
71 | ${CPP_WRAPPER_SOURCES_APP}
72 | )
73 | apply_standard_settings(flutter_wrapper_app)
74 | target_link_libraries(flutter_wrapper_app PUBLIC flutter)
75 | target_include_directories(flutter_wrapper_app PUBLIC
76 | "${WRAPPER_ROOT}/include"
77 | )
78 | add_dependencies(flutter_wrapper_app flutter_assemble)
79 |
80 | # === Flutter tool backend ===
81 | # _phony_ is a non-existent file to force this command to run every time,
82 | # since currently there's no way to get a full input/output list from the
83 | # flutter tool.
84 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
85 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
86 | add_custom_command(
87 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
88 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
89 | ${CPP_WRAPPER_SOURCES_APP}
90 | ${PHONY_OUTPUT}
91 | COMMAND ${CMAKE_COMMAND} -E env
92 | ${FLUTTER_TOOL_ENVIRONMENT}
93 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
94 | windows-x64 $
95 | VERBATIM
96 | )
97 | add_custom_target(flutter_assemble DEPENDS
98 | "${FLUTTER_LIBRARY}"
99 | ${FLUTTER_LIBRARY_HEADERS}
100 | ${CPP_WRAPPER_SOURCES_CORE}
101 | ${CPP_WRAPPER_SOURCES_PLUGIN}
102 | ${CPP_WRAPPER_SOURCES_APP}
103 | )
104 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.cc:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #include "generated_plugin_registrant.h"
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | void RegisterPlugins(flutter::PluginRegistry* registry) {
14 | IsarFlutterLibsPluginRegisterWithRegistrar(
15 | registry->GetRegistrarForPlugin("IsarFlutterLibsPlugin"));
16 | UrlLauncherWindowsRegisterWithRegistrar(
17 | registry->GetRegistrarForPlugin("UrlLauncherWindows"));
18 | WindowsPathProviderPluginRegisterWithRegistrar(
19 | registry->GetRegistrarForPlugin("WindowsPathProviderPlugin"));
20 | }
21 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugin_registrant.h:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // clang-format off
6 |
7 | #ifndef GENERATED_PLUGIN_REGISTRANT_
8 | #define GENERATED_PLUGIN_REGISTRANT_
9 |
10 | #include
11 |
12 | // Registers Flutter plugins.
13 | void RegisterPlugins(flutter::PluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | isar_flutter_libs
7 | url_launcher_windows
8 | windows_path_provider
9 | )
10 |
11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
12 | )
13 |
14 | set(PLUGIN_BUNDLED_LIBRARIES)
15 |
16 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
21 | endforeach(plugin)
22 |
23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
26 | endforeach(ffi_plugin)
27 |
--------------------------------------------------------------------------------
/windows/libs/libisar.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/windows/libs/libisar.dll
--------------------------------------------------------------------------------
/windows/runner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(runner LANGUAGES CXX)
3 |
4 | add_executable(${BINARY_NAME} WIN32
5 | "flutter_window.cpp"
6 | "main.cpp"
7 | "utils.cpp"
8 | "win32_window.cpp"
9 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
10 | "Runner.rc"
11 | "runner.exe.manifest"
12 | )
13 | apply_standard_settings(${BINARY_NAME})
14 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
15 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
16 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
17 | add_dependencies(${BINARY_NAME} flutter_assemble)
18 |
--------------------------------------------------------------------------------
/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #ifdef FLUTTER_BUILD_NUMBER
64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0
67 | #endif
68 |
69 | #ifdef FLUTTER_BUILD_NAME
70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "A new Flutter project." "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "files" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "files.exe" "\0"
98 | VALUE "ProductName", "files" "\0"
99 | VALUE "ProductVersion", VERSION_AS_STRING "\0"
100 | END
101 | END
102 | BLOCK "VarFileInfo"
103 | BEGIN
104 | VALUE "Translation", 0x409, 1252
105 | END
106 | END
107 |
108 | #endif // English (United States) resources
109 | /////////////////////////////////////////////////////////////////////////////
110 |
111 |
112 |
113 | #ifndef APSTUDIO_INVOKED
114 | /////////////////////////////////////////////////////////////////////////////
115 | //
116 | // Generated from the TEXTINCLUDE 3 resource.
117 | //
118 |
119 |
120 | /////////////////////////////////////////////////////////////////////////////
121 | #endif // not APSTUDIO_INVOKED
122 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.cpp:
--------------------------------------------------------------------------------
1 | #include "flutter_window.h"
2 |
3 | #include
4 |
5 | #include "flutter/generated_plugin_registrant.h"
6 |
7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8 | : project_(project) {}
9 |
10 | FlutterWindow::~FlutterWindow() {}
11 |
12 | bool FlutterWindow::OnCreate() {
13 | if (!Win32Window::OnCreate()) {
14 | return false;
15 | }
16 |
17 | RECT frame = GetClientArea();
18 |
19 | // The size here must match the window dimensions to avoid unnecessary surface
20 | // creation / destruction in the startup path.
21 | flutter_controller_ = std::make_unique(
22 | frame.right - frame.left, frame.bottom - frame.top, project_);
23 | // Ensure that basic setup of the controller was successful.
24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) {
25 | return false;
26 | }
27 | RegisterPlugins(flutter_controller_->engine());
28 | SetChildContent(flutter_controller_->view()->GetNativeWindow());
29 | return true;
30 | }
31 |
32 | void FlutterWindow::OnDestroy() {
33 | if (flutter_controller_) {
34 | flutter_controller_ = nullptr;
35 | }
36 |
37 | Win32Window::OnDestroy();
38 | }
39 |
40 | LRESULT
41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
42 | WPARAM const wparam,
43 | LPARAM const lparam) noexcept {
44 | // Give Flutter, including plugins, an opportunity to handle window messages.
45 | if (flutter_controller_) {
46 | std::optional result =
47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
48 | lparam);
49 | if (result) {
50 | return *result;
51 | }
52 | }
53 |
54 | switch (message) {
55 | case WM_FONTCHANGE:
56 | flutter_controller_->engine()->ReloadSystemFonts();
57 | break;
58 | }
59 |
60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
61 | }
62 |
--------------------------------------------------------------------------------
/windows/runner/flutter_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_FLUTTER_WINDOW_H_
2 | #define RUNNER_FLUTTER_WINDOW_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include "win32_window.h"
10 |
11 | // A window that does nothing but host a Flutter view.
12 | class FlutterWindow : public Win32Window {
13 | public:
14 | // Creates a new FlutterWindow hosting a Flutter view running |project|.
15 | explicit FlutterWindow(const flutter::DartProject& project);
16 | virtual ~FlutterWindow();
17 |
18 | protected:
19 | // Win32Window:
20 | bool OnCreate() override;
21 | void OnDestroy() override;
22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam,
23 | LPARAM const lparam) noexcept override;
24 |
25 | private:
26 | // The project to run.
27 | flutter::DartProject project_;
28 |
29 | // The Flutter instance hosted by this window.
30 | std::unique_ptr flutter_controller_;
31 | };
32 |
33 | #endif // RUNNER_FLUTTER_WINDOW_H_
34 |
--------------------------------------------------------------------------------
/windows/runner/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "flutter_window.h"
6 | #include "utils.h"
7 |
8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
9 | _In_ wchar_t *command_line, _In_ int show_command) {
10 | // Attach to console when present (e.g., 'flutter run') or create a
11 | // new console when running with a debugger.
12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
13 | CreateAndAttachConsole();
14 | }
15 |
16 | // Initialize COM, so that it is available for use in the library and/or
17 | // plugins.
18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
19 |
20 | flutter::DartProject project(L"data");
21 |
22 | std::vector command_line_arguments =
23 | GetCommandLineArguments();
24 |
25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26 |
27 | FlutterWindow window(project);
28 | Win32Window::Point origin(10, 10);
29 | Win32Window::Size size(1280, 720);
30 | if (!window.CreateAndShow(L"files", origin, size)) {
31 | return EXIT_FAILURE;
32 | }
33 | window.SetQuitOnClose(true);
34 |
35 | ::MSG msg;
36 | while (::GetMessage(&msg, nullptr, 0, 0)) {
37 | ::TranslateMessage(&msg);
38 | ::DispatchMessage(&msg);
39 | }
40 |
41 | ::CoUninitialize();
42 | return EXIT_SUCCESS;
43 | }
44 |
--------------------------------------------------------------------------------
/windows/runner/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Runner.rc
4 | //
5 | #define IDI_APP_ICON 101
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 102
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dahliaOS/files/4166d0ac3b31019f51c888eb2aa30671ac1e8c1a/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/windows/runner/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | void CreateAndAttachConsole() {
11 | if (::AllocConsole()) {
12 | FILE *unused;
13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
14 | _dup2(_fileno(stdout), 1);
15 | }
16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
17 | _dup2(_fileno(stdout), 2);
18 | }
19 | std::ios::sync_with_stdio();
20 | FlutterDesktopResyncOutputStreams();
21 | }
22 | }
23 |
24 | std::vector GetCommandLineArguments() {
25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use.
26 | int argc;
27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
28 | if (argv == nullptr) {
29 | return std::vector();
30 | }
31 |
32 | std::vector command_line_arguments;
33 |
34 | // Skip the first argument as it's the binary name.
35 | for (int i = 1; i < argc; i++) {
36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i]));
37 | }
38 |
39 | ::LocalFree(argv);
40 |
41 | return command_line_arguments;
42 | }
43 |
44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) {
45 | if (utf16_string == nullptr) {
46 | return std::string();
47 | }
48 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | if (target_length == 0) {
52 | return std::string();
53 | }
54 | std::string utf8_string;
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/windows/runner/utils.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_UTILS_H_
2 | #define RUNNER_UTILS_H_
3 |
4 | #include
5 | #include
6 |
7 | // Creates a console for the process, and redirects stdout and stderr to
8 | // it for both the runner and the Flutter library.
9 | void CreateAndAttachConsole();
10 |
11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string
12 | // encoded in UTF-8. Returns an empty std::string on failure.
13 | std::string Utf8FromUtf16(const wchar_t* utf16_string);
14 |
15 | // Gets the command line arguments passed in as a std::vector,
16 | // encoded in UTF-8. Returns an empty std::vector on failure.
17 | std::vector GetCommandLineArguments();
18 |
19 | #endif // RUNNER_UTILS_H_
20 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.cpp:
--------------------------------------------------------------------------------
1 | #include "win32_window.h"
2 |
3 | #include
4 |
5 | #include "resource.h"
6 |
7 | namespace {
8 |
9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
10 |
11 | // The number of Win32Window objects that currently exist.
12 | static int g_active_window_count = 0;
13 |
14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
15 |
16 | // Scale helper to convert logical scaler values to physical using passed in
17 | // scale factor
18 | int Scale(int source, double scale_factor) {
19 | return static_cast(source * scale_factor);
20 | }
21 |
22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
23 | // This API is only needed for PerMonitor V1 awareness mode.
24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) {
25 | HMODULE user32_module = LoadLibraryA("User32.dll");
26 | if (!user32_module) {
27 | return;
28 | }
29 | auto enable_non_client_dpi_scaling =
30 | reinterpret_cast(
31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
32 | if (enable_non_client_dpi_scaling != nullptr) {
33 | enable_non_client_dpi_scaling(hwnd);
34 | FreeLibrary(user32_module);
35 | }
36 | }
37 |
38 | } // namespace
39 |
40 | // Manages the Win32Window's window class registration.
41 | class WindowClassRegistrar {
42 | public:
43 | ~WindowClassRegistrar() = default;
44 |
45 | // Returns the singleton registar instance.
46 | static WindowClassRegistrar* GetInstance() {
47 | if (!instance_) {
48 | instance_ = new WindowClassRegistrar();
49 | }
50 | return instance_;
51 | }
52 |
53 | // Returns the name of the window class, registering the class if it hasn't
54 | // previously been registered.
55 | const wchar_t* GetWindowClass();
56 |
57 | // Unregisters the window class. Should only be called if there are no
58 | // instances of the window.
59 | void UnregisterWindowClass();
60 |
61 | private:
62 | WindowClassRegistrar() = default;
63 |
64 | static WindowClassRegistrar* instance_;
65 |
66 | bool class_registered_ = false;
67 | };
68 |
69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
70 |
71 | const wchar_t* WindowClassRegistrar::GetWindowClass() {
72 | if (!class_registered_) {
73 | WNDCLASS window_class{};
74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
75 | window_class.lpszClassName = kWindowClassName;
76 | window_class.style = CS_HREDRAW | CS_VREDRAW;
77 | window_class.cbClsExtra = 0;
78 | window_class.cbWndExtra = 0;
79 | window_class.hInstance = GetModuleHandle(nullptr);
80 | window_class.hIcon =
81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
82 | window_class.hbrBackground = 0;
83 | window_class.lpszMenuName = nullptr;
84 | window_class.lpfnWndProc = Win32Window::WndProc;
85 | RegisterClass(&window_class);
86 | class_registered_ = true;
87 | }
88 | return kWindowClassName;
89 | }
90 |
91 | void WindowClassRegistrar::UnregisterWindowClass() {
92 | UnregisterClass(kWindowClassName, nullptr);
93 | class_registered_ = false;
94 | }
95 |
96 | Win32Window::Win32Window() {
97 | ++g_active_window_count;
98 | }
99 |
100 | Win32Window::~Win32Window() {
101 | --g_active_window_count;
102 | Destroy();
103 | }
104 |
105 | bool Win32Window::CreateAndShow(const std::wstring& title,
106 | const Point& origin,
107 | const Size& size) {
108 | Destroy();
109 |
110 | const wchar_t* window_class =
111 | WindowClassRegistrar::GetInstance()->GetWindowClass();
112 |
113 | const POINT target_point = {static_cast(origin.x),
114 | static_cast(origin.y)};
115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
117 | double scale_factor = dpi / 96.0;
118 |
119 | HWND window = CreateWindow(
120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor),
123 | nullptr, nullptr, GetModuleHandle(nullptr), this);
124 |
125 | if (!window) {
126 | return false;
127 | }
128 |
129 | return OnCreate();
130 | }
131 |
132 | // static
133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window,
134 | UINT const message,
135 | WPARAM const wparam,
136 | LPARAM const lparam) noexcept {
137 | if (message == WM_NCCREATE) {
138 | auto window_struct = reinterpret_cast(lparam);
139 | SetWindowLongPtr(window, GWLP_USERDATA,
140 | reinterpret_cast(window_struct->lpCreateParams));
141 |
142 | auto that = static_cast(window_struct->lpCreateParams);
143 | EnableFullDpiSupportIfAvailable(window);
144 | that->window_handle_ = window;
145 | } else if (Win32Window* that = GetThisFromHandle(window)) {
146 | return that->MessageHandler(window, message, wparam, lparam);
147 | }
148 |
149 | return DefWindowProc(window, message, wparam, lparam);
150 | }
151 |
152 | LRESULT
153 | Win32Window::MessageHandler(HWND hwnd,
154 | UINT const message,
155 | WPARAM const wparam,
156 | LPARAM const lparam) noexcept {
157 | switch (message) {
158 | case WM_DESTROY:
159 | window_handle_ = nullptr;
160 | Destroy();
161 | if (quit_on_close_) {
162 | PostQuitMessage(0);
163 | }
164 | return 0;
165 |
166 | case WM_DPICHANGED: {
167 | auto newRectSize = reinterpret_cast(lparam);
168 | LONG newWidth = newRectSize->right - newRectSize->left;
169 | LONG newHeight = newRectSize->bottom - newRectSize->top;
170 |
171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
173 |
174 | return 0;
175 | }
176 | case WM_SIZE: {
177 | RECT rect = GetClientArea();
178 | if (child_content_ != nullptr) {
179 | // Size and position the child window.
180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
181 | rect.bottom - rect.top, TRUE);
182 | }
183 | return 0;
184 | }
185 |
186 | case WM_ACTIVATE:
187 | if (child_content_ != nullptr) {
188 | SetFocus(child_content_);
189 | }
190 | return 0;
191 | }
192 |
193 | return DefWindowProc(window_handle_, message, wparam, lparam);
194 | }
195 |
196 | void Win32Window::Destroy() {
197 | OnDestroy();
198 |
199 | if (window_handle_) {
200 | DestroyWindow(window_handle_);
201 | window_handle_ = nullptr;
202 | }
203 | if (g_active_window_count == 0) {
204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
205 | }
206 | }
207 |
208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
209 | return reinterpret_cast(
210 | GetWindowLongPtr(window, GWLP_USERDATA));
211 | }
212 |
213 | void Win32Window::SetChildContent(HWND content) {
214 | child_content_ = content;
215 | SetParent(content, window_handle_);
216 | RECT frame = GetClientArea();
217 |
218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
219 | frame.bottom - frame.top, true);
220 |
221 | SetFocus(child_content_);
222 | }
223 |
224 | RECT Win32Window::GetClientArea() {
225 | RECT frame;
226 | GetClientRect(window_handle_, &frame);
227 | return frame;
228 | }
229 |
230 | HWND Win32Window::GetHandle() {
231 | return window_handle_;
232 | }
233 |
234 | void Win32Window::SetQuitOnClose(bool quit_on_close) {
235 | quit_on_close_ = quit_on_close;
236 | }
237 |
238 | bool Win32Window::OnCreate() {
239 | // No-op; provided for subclasses.
240 | return true;
241 | }
242 |
243 | void Win32Window::OnDestroy() {
244 | // No-op; provided for subclasses.
245 | }
246 |
--------------------------------------------------------------------------------
/windows/runner/win32_window.h:
--------------------------------------------------------------------------------
1 | #ifndef RUNNER_WIN32_WINDOW_H_
2 | #define RUNNER_WIN32_WINDOW_H_
3 |
4 | #include
5 |
6 | #include
7 | #include
8 | #include
9 |
10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11 | // inherited from by classes that wish to specialize with custom
12 | // rendering and input handling
13 | class Win32Window {
14 | public:
15 | struct Point {
16 | unsigned int x;
17 | unsigned int y;
18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19 | };
20 |
21 | struct Size {
22 | unsigned int width;
23 | unsigned int height;
24 | Size(unsigned int width, unsigned int height)
25 | : width(width), height(height) {}
26 | };
27 |
28 | Win32Window();
29 | virtual ~Win32Window();
30 |
31 | // Creates and shows a win32 window with |title| and position and size using
32 | // |origin| and |size|. New windows are created on the default monitor. Window
33 | // sizes are specified to the OS in physical pixels, hence to ensure a
34 | // consistent size to will treat the width height passed in to this function
35 | // as logical pixels and scale to appropriate for the default monitor. Returns
36 | // true if the window was created successfully.
37 | bool CreateAndShow(const std::wstring& title,
38 | const Point& origin,
39 | const Size& size);
40 |
41 | // Release OS resources associated with window.
42 | void Destroy();
43 |
44 | // Inserts |content| into the window tree.
45 | void SetChildContent(HWND content);
46 |
47 | // Returns the backing Window handle to enable clients to set icon and other
48 | // window properties. Returns nullptr if the window has been destroyed.
49 | HWND GetHandle();
50 |
51 | // If true, closing this window will quit the application.
52 | void SetQuitOnClose(bool quit_on_close);
53 |
54 | // Return a RECT representing the bounds of the current client area.
55 | RECT GetClientArea();
56 |
57 | protected:
58 | // Processes and route salient window messages for mouse handling,
59 | // size change and DPI. Delegates handling of these to member overloads that
60 | // inheriting classes can handle.
61 | virtual LRESULT MessageHandler(HWND window,
62 | UINT const message,
63 | WPARAM const wparam,
64 | LPARAM const lparam) noexcept;
65 |
66 | // Called when CreateAndShow is called, allowing subclass window-related
67 | // setup. Subclasses should return false if setup fails.
68 | virtual bool OnCreate();
69 |
70 | // Called when Destroy is called.
71 | virtual void OnDestroy();
72 |
73 | private:
74 | friend class WindowClassRegistrar;
75 |
76 | // OS callback called by message pump. Handles the WM_NCCREATE message which
77 | // is passed when the non-client area is being created and enables automatic
78 | // non-client DPI scaling so that the non-client area automatically
79 | // responsponds to changes in DPI. All other messages are handled by
80 | // MessageHandler.
81 | static LRESULT CALLBACK WndProc(HWND const window,
82 | UINT const message,
83 | WPARAM const wparam,
84 | LPARAM const lparam) noexcept;
85 |
86 | // Retrieves a class instance pointer for |window|
87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept;
88 |
89 | bool quit_on_close_ = false;
90 |
91 | // window handle for top level window.
92 | HWND window_handle_ = nullptr;
93 |
94 | // window handle for hosted content.
95 | HWND child_content_ = nullptr;
96 | };
97 |
98 | #endif // RUNNER_WIN32_WINDOW_H_
99 |
--------------------------------------------------------------------------------