Files
adventofcode2025/lib/day_page.dart

82 lines
2.2 KiB
Dart
Raw Normal View History

2026-03-17 16:14:41 -05:00
import "util.dart";
import 'package:adventofcode2025/main.dart';
2026-02-21 21:32:56 -06:00
import 'package:file_picker/file_picker.dart';
2026-02-21 15:56:39 -06:00
import 'package:flutter/material.dart';
2026-03-17 16:14:41 -05:00
import 'package:provider/provider.dart';
import "days_enum.dart";
2026-02-21 15:56:39 -06:00
2026-03-17 16:14:41 -05:00
Future<String?> selectFile() async {
debugLog("selectFile Button pushed");
2026-02-21 21:32:56 -06:00
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
//File file = File(result.files.single.path!);
2026-03-17 16:14:41 -05:00
debugLog(result.files.single.path!);
return result.files.single.path;
2026-02-21 21:32:56 -06:00
} else {
2026-03-17 16:14:41 -05:00
return null;
2026-02-21 21:32:56 -06:00
}
2026-02-21 15:56:39 -06:00
}
class DayPage extends StatelessWidget {
2026-03-17 16:14:41 -05:00
final AdventOfCodeDays day;
const DayPage(this.day, {super.key});
2026-02-21 15:56:39 -06:00
@override
Widget build(BuildContext context) {
2026-03-17 16:14:41 -05:00
var state = context.watch<MyAppState>();
2026-02-21 15:56:39 -06:00
return Center(
child: Column(
children: [
Row(
children: [
2026-03-17 16:14:41 -05:00
TextButton(
onPressed: () async {
var selectedFile = await selectFile();
state.setSelectedFile(day, selectedFile);
},
child: Text("Select Input"),
),
2026-02-21 15:56:39 -06:00
SizedBox(
width: 300,
child: TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
2026-03-17 16:14:41 -05:00
//hintText: 'Input File Path',
hintText: state.getSelectedFile(day),
2026-02-21 15:56:39 -06:00
),
),
),
],
),
Row(
2026-03-17 16:14:41 -05:00
children: [
TextButton(
onPressed: () async {
debugLog("RUNNING $day!");
},
child: Text("Run"),
),
],
2026-02-21 15:56:39 -06:00
),
Expanded(
child: Row(
children: [
Expanded(
child: TextField(
decoration: InputDecoration(border: OutlineInputBorder()),
readOnly: true,
expands: true,
minLines: null,
maxLines: null,
),
),
],
),
),
],
),
);
}
}