Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit e21dbc3

Browse files
committed
feat: add file selecter
1 parent 5e4481a commit e21dbc3

10 files changed

+265
-78
lines changed

.github/workflows/flutterci.yml

+46
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
- uses: actions/checkout@v2
6060
- uses: subosito/[email protected]
6161
with:
62+
channel: beta
6263
cache: true
6364
- run: flutter config --enable-windows-desktop
6465
- run: flutter build windows
@@ -85,6 +86,7 @@ jobs:
8586
scripts/Output/TModInstaller-windows-x86_64-setup.exe
8687
TModInstaller-windows-x86_64.zip
8788
token: ${{ secrets.GITHUB_TOKEN }}
89+
8890
build_linux:
8991
if: startsWith(github.ref, 'refs/tags/v')
9092
needs: test
@@ -139,6 +141,50 @@ jobs:
139141
files: tmodinstaller-linux-*
140142
token: ${{ secrets.GITHUB_TOKEN }}
141143

144+
# macos-Build:
145+
# if: startsWith(github.ref, 'refs/tags/v')
146+
# runs-on: macos-11
147+
# steps:
148+
# - uses: actions/checkout@v2
149+
# - name: Cache flutter
150+
# uses: actions/cache@v2
151+
# with:
152+
# path: ${{ runner.tool_cache }}/flutter
153+
# key: ${{ runner.os }}-2.10.0-0.3.pre
154+
# - uses: subosito/flutter-action@master
155+
# with:
156+
# channel: beta
157+
# flutter-version: 2.10.0-0.2.pre
158+
# - name: Build
159+
# run: |
160+
# flutter pub get
161+
# flutter config --enable-macos-desktop
162+
# dart pub global activate cider
163+
# dart pub global run cider version ${{ env.rwl_version_full }}
164+
# flutter build macos --dart-define="build_id=${{ github.run_number }}" --dart-define="version_type=${{ env.version_type }}" --dart-define="version=${{ secrets.VERSION }}" --release
165+
# cp assets/images/MacOS_Logo_Icon.icns build/macos/Build/Products
166+
# cd build/macos/Build/Products
167+
# brew install create-dmg
168+
# create-dmg \
169+
# --volname "TModInstaller" \
170+
# --volicon "MacOS_Logo_Icon.icns" \
171+
# --window-pos 200 120 \
172+
# --window-size 800 529 \
173+
# --icon-size 130 \
174+
# --text-size 14 \
175+
# --icon "TModInstaller.app" 260 250 \
176+
# --hide-extension "TModInstaller.app" \
177+
# --app-drop-link 540 250 \
178+
# --hdiutil-quiet \
179+
# "TModInstaller-MacOS-Installer.dmg" \
180+
# "Release/"
181+
# continue-on-error: true
182+
# - name: Update File
183+
# uses: actions/upload-artifact@v2
184+
# with:
185+
# name: TMod Instakker-MacOS
186+
# path: build/macos/Build/Products/TMod Instakker-MacOS-Installer.dmg
187+
# retention-days: 1
142188
# build_android:
143189
# if: startsWith(github.ref, 'refs/tags/v')
144190
# needs: test

lib/src/screens/launcher.dart

+62-34
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// You should have received a copy of the license along with this
77
// work. If not, see <http://creativecommons.org/licenses/by-nc-nd/3.0/>.
88

9+
import 'package:file_selector/file_selector.dart';
910
import 'package:fluent_ui/fluent_ui.dart';
1011
import 'package:flutter/material.dart' as flutter;
1112
import 'package:tmodinstaller/config.dart';
@@ -81,41 +82,68 @@ class _LauncherState extends State<Launcher> {
8182
"Current directory $_modfolder ${_modfolder == Config.directory ? "(Default)" : ""}",
8283
),
8384
spacer,
84-
TextBox(
85-
placeholder: 'Change ',
86-
onEditingComplete: () {},
87-
onChanged: (v) {
88-
_newmodfolder = v;
89-
},
90-
suffix: IconButton(
91-
icon: const Icon(FluentIcons.add_to),
92-
onPressed: () async {
93-
var fold = _newmodfolder
94-
.replaceFirst(
95-
"~", Platform.environment['HOME'] ?? "NO_HOME")
96-
.replaceFirst("%APPDATA%",
97-
Platform.environment['APPDATA'] ?? "NO_APPDATA");
98-
var r = await Directory(fold).exists();
99-
if (r) {
100-
final data = Version()
101-
..version = widget.mcv
102-
..moddir = fold;
103-
if (version?.id != null) {
104-
data.id = version?.id;
105-
}
106-
await Config.isar.writeTxn((isar) async {
107-
data.id = await isar.versions.put(data);
108-
});
109-
setState(() {});
110-
} else {
111-
showDialog(
112-
context: context,
113-
builder: (BuildContext context) => _invaliddir(context),
114-
);
85+
FilledButton(
86+
child: Text("Select new directory"),
87+
onPressed: () async {
88+
var dir = await getDirectoryPath(
89+
initialDirectory: _modfolder,
90+
);
91+
if (dir == null) return;
92+
var r = await Directory(dir).exists();
93+
if (r) {
94+
final data = Version()
95+
..version = widget.mcv
96+
..moddir = dir;
97+
if (version?.id != null) {
98+
data.id = version?.id;
11599
}
116-
},
117-
),
118-
),
100+
await Config.isar.writeTxn((isar) async {
101+
data.id = await isar.versions.put(data);
102+
});
103+
setState(() {});
104+
} else {
105+
showDialog(
106+
context: context,
107+
builder: (BuildContext context) => _invaliddir(context),
108+
);
109+
}
110+
},
111+
)
112+
// TextBox(
113+
// placeholder: 'Change ',
114+
// onEditingComplete: () {},
115+
// onChanged: (v) {
116+
// _newmodfolder = v;
117+
// },
118+
// suffix: IconButton(
119+
// icon: const Icon(FluentIcons.add_to),
120+
// onPressed: () async {
121+
// var fold = _newmodfolder
122+
// .replaceFirst(
123+
// "~", Platform.environment['HOME'] ?? "NO_HOME")
124+
// .replaceFirst("%APPDATA%",
125+
// Platform.environment['APPDATA'] ?? "NO_APPDATA");
126+
// var r = await Directory(fold).exists();
127+
// if (r) {
128+
// final data = Version()
129+
// ..version = widget.mcv
130+
// ..moddir = fold;
131+
// if (version?.id != null) {
132+
// data.id = version?.id;
133+
// }
134+
// await Config.isar.writeTxn((isar) async {
135+
// data.id = await isar.versions.put(data);
136+
// });
137+
// setState(() {});
138+
// } else {
139+
// showDialog(
140+
// context: context,
141+
// builder: (BuildContext context) => _invaliddir(context),
142+
// );
143+
// }
144+
// },
145+
// ),
146+
// ),
119147
]);
120148
}
121149

lib/src/screens/settings.dart

+54-32
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// You should have received a copy of the license along with this
77
// work. If not, see <http://creativecommons.org/licenses/by-nc-nd/3.0/>.
88

9+
import 'package:file_selector/file_selector.dart';
910
import 'package:fluent_ui/fluent_ui.dart';
1011
import 'package:flutter/material.dart' as flutter;
1112
import 'package:provider/provider.dart';
@@ -183,40 +184,61 @@ class _SettingsState extends State<Settings> {
183184
"Current directory $modfolder",
184185
),
185186
spacer,
186-
TextBox(
187-
// controller: _clearController,
188-
// header: 'Repos split by ","',
189-
placeholder: 'Change modfolder',
190-
onEditingComplete: () {
191-
// print("Hello!");
192-
// Config.preferences?.setStringList("repos", current.split(","));
193-
},
194-
onChanged: (v) {
195-
_modfolder = v;
187+
FilledButton(
188+
child: Text("Select new directory"),
189+
onPressed: () async {
190+
var dir = await getDirectoryPath(
191+
initialDirectory: _modfolder,
192+
);
193+
if (dir == null) return;
194+
var r = await Directory(dir).exists();
195+
if (r) {
196+
setState(() {
197+
Config.preferences?.setString("modfolder", dir);
198+
});
199+
setState(() {});
200+
} else {
201+
showDialog(
202+
context: context,
203+
builder: (BuildContext context) => _invaliddir(),
204+
);
205+
}
196206
},
197-
suffix: IconButton(
198-
icon: const Icon(FluentIcons.add_to),
199-
onPressed: () async {
200-
var fold = _modfolder
201-
.replaceFirst("~", Platform.environment['HOME'] ?? "NO_HOME")
202-
.replaceFirst("%APPDATA%",
203-
Platform.environment['APPDATA'] ?? "NO_APPDATA");
204-
var r = await Directory(fold).exists();
205-
if (r) {
206-
setState(() {
207-
Config.preferences?.setString("modfolder", fold);
208-
});
209-
} else {
210-
showDialog(
211-
context: context,
212-
builder: (BuildContext context) => _invaliddir(),
213-
);
214-
}
215-
216-
// _clearController.clear();
217-
},
218-
),
219207
),
208+
// TextBox(
209+
// // controller: _clearController,
210+
// // header: 'Repos split by ","',
211+
// placeholder: 'Change modfolder',
212+
// onEditingComplete: () {
213+
// // print("Hello!");
214+
// // Config.preferences?.setStringList("repos", current.split(","));
215+
// },
216+
// onChanged: (v) {
217+
// _modfolder = v;
218+
// },
219+
// suffix: IconButton(
220+
// icon: const Icon(FluentIcons.add_to),
221+
// onPressed: () async {
222+
// var fold = _modfolder
223+
// .replaceFirst("~", Platform.environment['HOME'] ?? "NO_HOME")
224+
// .replaceFirst("%APPDATA%",
225+
// Platform.environment['APPDATA'] ?? "NO_APPDATA");
226+
// var r = await Directory(fold).exists();
227+
// if (r) {
228+
// setState(() {
229+
// Config.preferences?.setString("modfolder", fold);
230+
// });
231+
// } else {
232+
// showDialog(
233+
// context: context,
234+
// builder: (BuildContext context) => _invaliddir(),
235+
// );
236+
// }
237+
238+
// // _clearController.clear();
239+
// },
240+
// ),
241+
// ),
220242
biggerSpacer,
221243
Row(
222244
children: [

linux/flutter/generated_plugin_registrant.cc

+4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <file_selector_linux/file_selector_plugin.h>
910
#include <flutter_acrylic/flutter_acrylic_plugin.h>
1011
#include <isar_flutter_libs/isar_flutter_libs_plugin.h>
1112
#include <url_launcher_linux/url_launcher_plugin.h>
1213
#include <window_manager/window_manager_plugin.h>
1314

1415
void fl_register_plugins(FlPluginRegistry* registry) {
16+
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
17+
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
18+
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
1519
g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar =
1620
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin");
1721
flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar);

linux/flutter/generated_plugins.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
file_selector_linux
67
flutter_acrylic
78
isar_flutter_libs
89
url_launcher_linux

0 commit comments

Comments
 (0)