ANDREAS_LATANOWSKY_CPD_1910877/lib/main.dart

123 lines
3.8 KiB
Dart

import 'dart:ui';
import 'package:cpd_app/image_translator.dart';
import 'package:cpd_app/ocr_page.dart';
import 'package:cpd_app/session_list_view.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
FlutterView? flutterView = PlatformDispatcher.instance.views.firstOrNull;
if (flutterView == null || flutterView.physicalSize.isEmpty) {
PlatformDispatcher.instance.onMetricsChanged = () {
flutterView = PlatformDispatcher.instance.views.firstOrNull;
if (flutterView != null && !flutterView!.physicalSize.isEmpty) {
PlatformDispatcher.instance.onMetricsChanged = null;
runApp(const MyApp());
}
};
} else {
runApp(const MyApp());
}
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: OpticText(),
);
}
}
class OpticText extends StatelessWidget {
const OpticText({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color.fromARGB(99, 78, 72, 72),
appBar: AppBar(
backgroundColor: const Color.fromARGB(255, 161, 120, 17),
title: const Text('Optic Text'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const ImageToolsPage()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 161, 120, 17),
foregroundColor: const Color.fromARGB(255, 0, 0, 0)),
child: const Text('Image Tools'),
),
),
);
}
}
class ImageToolsPage extends StatelessWidget {
const ImageToolsPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color.fromARGB(99, 78, 72, 72),
appBar: AppBar(
backgroundColor: const Color.fromARGB(255, 161, 120, 17),
title: const Text('Image Tools'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
key: const Key('ocr_button'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => const OCRPage()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 161, 120, 17),
foregroundColor: const Color.fromARGB(255, 0, 0, 0)),
child: const Text('OCR'),
),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ImageTranslation()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 161, 120, 17),
foregroundColor: const Color.fromARGB(255, 0, 0, 0)),
child: const Text('Image Translation'),
),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SessionListView()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 161, 120, 17),
foregroundColor: const Color.fromARGB(255, 0, 0, 0)),
child: const Text('Previous Images'),
),
],
),
),
);
}
}