Resolve merge conflicts: README + ignore IDE files
This commit is contained in:
62
lib/app.dart
62
lib/app.dart
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'models/auth_session.dart';
|
||||
import 'screens/auth_screen.dart';
|
||||
import 'screens/dashboard_screen.dart';
|
||||
import 'services/address_repository.dart';
|
||||
import 'services/auth_repository.dart';
|
||||
|
||||
@@ -12,8 +10,8 @@ class MyApp extends StatelessWidget {
|
||||
AuthRepository? authRepository,
|
||||
AddressRepository? addressRepository,
|
||||
this.enableLiveFeatures = true,
|
||||
}) : _authRepository = authRepository ?? const HttpAuthRepository(),
|
||||
_addressRepository = addressRepository ?? const HttpAddressRepository();
|
||||
}) : _authRepository = authRepository ?? const LocalAuthRepository(),
|
||||
_addressRepository = addressRepository ?? const LocalAddressRepository();
|
||||
|
||||
final AuthRepository _authRepository;
|
||||
final AddressRepository _addressRepository;
|
||||
@@ -37,7 +35,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class AuthBootstrap extends StatefulWidget {
|
||||
class AuthBootstrap extends StatelessWidget {
|
||||
const AuthBootstrap({
|
||||
super.key,
|
||||
required this.authRepository,
|
||||
@@ -49,58 +47,12 @@ class AuthBootstrap extends StatefulWidget {
|
||||
final AddressRepository addressRepository;
|
||||
final bool enableLiveFeatures;
|
||||
|
||||
@override
|
||||
State<AuthBootstrap> createState() => _AuthBootstrapState();
|
||||
}
|
||||
|
||||
class _AuthBootstrapState extends State<AuthBootstrap> {
|
||||
late final Future<AuthSession?> _sessionFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_sessionFuture = widget.authRepository.restoreSession();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<AuthSession?>(
|
||||
future: _sessionFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const _LoadingView();
|
||||
}
|
||||
|
||||
final session = snapshot.data;
|
||||
if (session != null) {
|
||||
return DashboardScreen(
|
||||
authRepository: widget.authRepository,
|
||||
addressRepository: widget.addressRepository,
|
||||
session: session,
|
||||
savedAddress: null,
|
||||
enableLiveFeatures: widget.enableLiveFeatures,
|
||||
);
|
||||
}
|
||||
|
||||
return AuthScreen(
|
||||
authRepository: widget.authRepository,
|
||||
addressRepository: widget.addressRepository,
|
||||
enableLiveFeatures: widget.enableLiveFeatures,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LoadingView extends StatelessWidget {
|
||||
const _LoadingView();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
return AuthScreen(
|
||||
authRepository: authRepository,
|
||||
addressRepository: addressRepository,
|
||||
enableLiveFeatures: enableLiveFeatures,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user