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