mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-14 03:32:23 +01:00
Initial commit
This commit is contained in:
52
lib/src/widget/select_file.dart
Normal file
52
lib/src/widget/select_file.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_desktop_folder_picker/flutter_desktop_folder_picker.dart';
|
||||
|
||||
class SelectFile extends StatefulWidget {
|
||||
final String label;
|
||||
final String placeholder;
|
||||
final String windowTitle;
|
||||
final bool allowNavigator;
|
||||
final TextEditingController controller;
|
||||
final String? Function(String?) validator;
|
||||
|
||||
const SelectFile(
|
||||
{required this.label,
|
||||
required this.placeholder,
|
||||
required this.windowTitle,
|
||||
required this.controller,
|
||||
required this.validator,
|
||||
this.allowNavigator = true,
|
||||
Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<SelectFile> createState() => _SelectFileState();
|
||||
}
|
||||
|
||||
class _SelectFileState extends State<SelectFile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InfoLabel(
|
||||
label: widget.label,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormBox(
|
||||
controller: widget.controller,
|
||||
placeholder: widget.placeholder,
|
||||
validator: widget.validator)),
|
||||
if (widget.allowNavigator) const SizedBox(width: 8.0),
|
||||
if (widget.allowNavigator)
|
||||
IconButton(
|
||||
icon: const Icon(FluentIcons.open_folder_horizontal),
|
||||
onPressed: _onPressed)
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
void _onPressed() async {
|
||||
var result = await FlutterDesktopFolderPicker.openFolderPickerDialog(
|
||||
title: "Select the game folder");
|
||||
widget.controller.text = result ?? "";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user