2024-11-10 01:19:14 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2024-11-05 18:05:16 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2024-11-10 01:19:14 +00:00
|
|
|
|
|
|
|
import 'profile_screen.dart';
|
|
|
|
import 'shared_preferences_provider.dart';
|
|
|
|
import 'status_page.dart';
|
2024-11-05 18:05:16 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(
|
|
|
|
ChangeNotifierProvider(
|
|
|
|
create: (_) => SharedPreferencesProvider(),
|
|
|
|
child: const MyApp(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatefulWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
MyAppState createState() => MyAppState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyAppState extends State<MyApp> {
|
|
|
|
Future<void>? _prefsReady;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_prefsReady =
|
|
|
|
Provider.of<SharedPreferencesProvider>(context, listen: false).ready;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Pogdark',
|
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
|
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
home: FutureBuilder(
|
|
|
|
future: _prefsReady,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
|
|
if (Provider.of<SharedPreferencesProvider>(context).getUserName() !=
|
|
|
|
'') {
|
2024-11-10 01:19:14 +00:00
|
|
|
return const StatusPage();
|
2024-11-05 18:05:16 +00:00
|
|
|
} else {
|
|
|
|
return const ProfileScreen(isEditing: false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return const Center(child: CircularProgressIndicator());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|