2024-07-24 14:30:00 -07:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-12-24 20:35:24 -07:00
|
|
|
import 'package:flutter/material.dart';
|
2023-12-25 16:51:24 -07:00
|
|
|
import 'package:nbteditor/Editor.dart';
|
2024-06-07 01:05:22 -07:00
|
|
|
import 'package:nbteditor/pages/AddPage.dart';
|
2024-07-02 20:13:02 -07:00
|
|
|
import 'package:nbteditor/pages/SNBTEditor.dart';
|
2024-07-24 07:07:34 -07:00
|
|
|
import 'package:nbteditor/pages/permsrequired.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
2023-12-24 20:35:24 -07:00
|
|
|
|
2024-07-24 17:33:55 -07:00
|
|
|
void main() async {
|
2024-07-27 18:10:04 -07:00
|
|
|
runApp(const MainApp());
|
2023-12-24 20:35:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class MainApp extends StatelessWidget {
|
2024-07-27 18:10:04 -07:00
|
|
|
const MainApp({
|
2024-07-24 17:33:55 -07:00
|
|
|
super.key,
|
|
|
|
});
|
2023-12-24 20:35:24 -07:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-12-25 16:51:24 -07:00
|
|
|
return MaterialApp(
|
|
|
|
theme: ThemeData.dark(),
|
2024-06-07 01:05:22 -07:00
|
|
|
routes: {
|
2024-07-24 17:33:55 -07:00
|
|
|
"/": (context) => const Editor(),
|
2024-07-21 03:13:12 -07:00
|
|
|
"/add": (context) => const AddPage(),
|
2024-07-21 06:05:32 -07:00
|
|
|
"/snbt": (context) => const SnbtEdit(),
|
2024-07-24 07:07:56 -07:00
|
|
|
"/perms": (context) => const PermissionsRequiredPage()
|
2024-06-07 01:05:22 -07:00
|
|
|
},
|
2023-12-24 20:35:24 -07:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2024-07-24 07:07:34 -07:00
|
|
|
|
2024-07-24 17:33:55 -07:00
|
|
|
bool needsPermissions() {
|
|
|
|
return Platform.isIOS || Platform.isMacOS || Platform.isAndroid;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> needsPermissionsPage() async {
|
|
|
|
if (needsPermissions()) {
|
|
|
|
if (await Permission.manageExternalStorage.isDenied) {
|
|
|
|
return true;
|
2024-07-27 18:10:04 -07:00
|
|
|
} else {
|
2024-07-24 17:33:55 -07:00
|
|
|
return false;
|
2024-07-27 18:10:04 -07:00
|
|
|
}
|
|
|
|
} else {
|
2024-07-24 17:33:55 -07:00
|
|
|
return false;
|
2024-07-27 18:10:04 -07:00
|
|
|
}
|
2024-07-24 17:33:55 -07:00
|
|
|
}
|