Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Nopylacetat
2023-10-20 18:16:12 +02:00
5 changed files with 347 additions and 3 deletions

View File

@@ -1,8 +1,11 @@
import 'package:flutter/material.dart';
import 'package:maggs_victory_voyage/services/db_helper.dart';
import 'pages/login_page.dart';
import 'pages/splash_page.dart';
void main() {
void main() async {
await DbHelper.init();
runApp(const Application());
}
@@ -17,7 +20,7 @@ class Application extends StatelessWidget {
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const LoginPage(),
home: const SplashPage(),
);
}
}

View File

@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
import 'login_page.dart';
class SplashPage extends StatefulWidget {
const SplashPage({super.key});
@override
State<SplashPage> createState() => _SplashPageState();
}
class _SplashPageState extends State<SplashPage> {
@override
Widget build(BuildContext context) {
return const LoginPage();
}
}

View File

@@ -1,9 +1,20 @@
import 'package:shared_preferences/shared_preferences.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
class DbHelper {
static Future<SharedPreferences> get _prefs async =>
SharedPreferences.getInstance();
static final _supabase = Supabase.instance.client;
static Future<void> init() async {
await Supabase.initialize(
url: 'https://vhmrtvhcmvylhrhblyjb.supabase.co',
anonKey:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZobXJ0dmhjbXZ5bGhyaGJseWpiIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTc4MTU3MTksImV4cCI6MjAxMzM5MTcxOX0.Djltae5oIvANqHdY1cNqA1ja5aAEivr-a_XDYkSd924',
);
}
static void login(String username) async {
final prefs = await _prefs;
final String? savedUsername = prefs.getString('username');