2023-09-06 23:38:53 +00:00
|
|
|
import 'package:dartterm/colors.dart';
|
2023-09-10 03:26:30 +00:00
|
|
|
import 'package:dartterm/input.dart' as input;
|
2023-09-10 01:40:56 +00:00
|
|
|
import 'package:dartterm/game.dart' as game;
|
|
|
|
import 'package:dartterm/terminal.dart' as terminal;
|
2023-09-06 03:11:15 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/scheduler.dart';
|
|
|
|
|
|
|
|
void main() {
|
2023-09-20 02:19:26 +00:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2023-09-10 22:29:51 +00:00
|
|
|
game.main();
|
2023-09-06 19:15:45 +00:00
|
|
|
runApp(const App());
|
2023-09-06 03:11:15 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 19:15:45 +00:00
|
|
|
class App extends StatelessWidget {
|
|
|
|
const App({super.key});
|
2023-09-06 03:11:15 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'DARTTERM',
|
|
|
|
theme: ThemeData(
|
2023-09-06 23:38:53 +00:00
|
|
|
useMaterial3: true, scaffoldBackgroundColor: Palette.defaultBg),
|
2023-09-06 03:11:15 +00:00
|
|
|
builder: (BuildContext context, Widget? child) {
|
|
|
|
return MediaQuery(
|
|
|
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
|
|
|
child: child!);
|
|
|
|
},
|
2023-09-06 19:15:45 +00:00
|
|
|
home: const Viewer(),
|
2023-09-06 03:11:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-06 19:15:45 +00:00
|
|
|
class Viewer extends StatefulWidget {
|
|
|
|
const Viewer({super.key});
|
2023-09-06 03:11:15 +00:00
|
|
|
|
|
|
|
@override
|
2023-09-06 19:15:45 +00:00
|
|
|
State<Viewer> createState() => _ViewerState();
|
2023-09-06 03:11:15 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 19:15:45 +00:00
|
|
|
class _ViewerState extends State<Viewer> {
|
2023-09-06 03:11:15 +00:00
|
|
|
Ticker? ticker;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
ticker = Ticker(tick);
|
|
|
|
ticker!.start();
|
2023-09-10 03:26:30 +00:00
|
|
|
input.startListening();
|
2023-09-06 03:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-09-06 23:38:53 +00:00
|
|
|
return Scaffold(
|
|
|
|
body: Center(
|
|
|
|
child: AspectRatio(
|
2023-09-10 01:40:56 +00:00
|
|
|
aspectRatio: terminal.width / terminal.height,
|
|
|
|
child: terminal.toWidget(context)),
|
2023-09-06 23:38:53 +00:00
|
|
|
));
|
2023-09-06 03:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void tick(Duration elapsed) {
|
|
|
|
setState(() {/* state changed, force a redraw */});
|
|
|
|
}
|
|
|
|
}
|