import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import '../features/auth/presentation/welcome_screen.dart';
import '../features/dashboard/presentation/app_shell.dart';
import '../core/auth/auth_store.dart';
import 'theme.dart';
class MachweisApp extends StatelessWidget {
const MachweisApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp(
title: 'MACHWEIS',
debugShowCheckedModeBanner: false,
theme: MachweisTheme.light,
locale: const Locale('de', 'DE'),
supportedLocales: const [Locale('de', 'DE')],
localizationsDelegates: GlobalMaterialLocalizations.delegates,
home: ListenableBuilder(
listenable: AuthStore.instance,
builder: (_, _) => AuthStore.instance.isSignedIn
? AppShell(key: ValueKey(AuthStore.instance.session?.tenantId))
: WelcomeScreen(invitationToken: kIsWeb ? _invitationToken() : null),
),
);
String? _invitationToken() {
final fragment = Uri.base.fragment;
if (!fragment.startsWith('invite=')) return null;
final token = Uri.decodeComponent(fragment.substring('invite='.length));
return token.isEmpty ? null : token;
}
}
