OpenMediacenterMobileFlutter/lib/app.dart
2021-12-10 11:40:20 +01:00

58 lines
1.3 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:openmediacentermobile/login_screen.dart';
import 'package:openmediacentermobile/token.dart';
import 'video_feed.dart';
class App extends StatefulWidget {
App({Key? key}) : super(key: key) {}
@override
State<StatefulWidget> createState() {
return AppState();
}
}
class AppState extends State<App> {
String? loggedin = null;
onLogin() {
setState(() {
loggedin = "ddd";
});
}
@override
Widget build(BuildContext context) {
if (loggedin == null) {
return const CircularProgressIndicator();
} else if (loggedin == "") {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Login"),
),
body: LoginScreen(onLogin: onLogin)));
} else {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("Openmediacenter"),
),
body: VideoFeed()));
}
}
AppState() {
final token = Token.getInstance();
token.getToken().then((value) {
Logger().i("The token value is $value");
setState(() {
loggedin = value;
});
});
}
}