Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed assets/icons/.gitkeep
Empty file.
Binary file added assets/icons/icon_1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions lib/core/router/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ import 'route_guard.dart';

part 'app_router.g.dart';

@riverpod
class _RouterNotifier extends ChangeNotifier {
void notify() => notifyListeners();
}

@Riverpod(keepAlive: true)
GoRouter appRouter(Ref ref) {
final authState = ref.watch(currentAuthStateProvider);
final notifier = _RouterNotifier();

ref.listen(currentAuthStateProvider, (_, __) => notifier.notify());
ref.onDispose(notifier.dispose);

return GoRouter(
initialLocation: AppRoutes.login,
debugLogDiagnostics: false,
refreshListenable: notifier,
redirect: (context, state) => RouteGuard.redirect(
state: state,
authState: authState,
authState: ref.read(currentAuthStateProvider),
),
routes: [
GoRoute(
Expand Down
204 changes: 112 additions & 92 deletions lib/features/auth/presentation/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,122 +41,142 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
ref.listen(authStateProvider, (_, next) {
next.whenOrNull(
error: (e, _) => ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(e.toString()), backgroundColor: AppColors.error),
SnackBar(
content: Text(e.toString()),
backgroundColor: AppColors.error),
),
);
});

return Scaffold(
backgroundColor: AppColors.background,
// SafeArea + SingleChildScrollView prevents the form from being hidden
// behind the soft keyboard on short screens.
body: SafeArea(
child: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
MediaQuery.of(context).padding.bottom,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: Card(
// LayoutBuilder + IntrinsicHeight keeps the card vertically centred
// on desktop while SingleChildScrollView prevents keyboard overflow
// on mobile/short screens.
child: LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: IntrinsicHeight(
child: Column(
children: [
Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(40),
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
padding: const EdgeInsets.symmetric(
horizontal: 24, vertical: 32),
child: ConstrainedBox(
constraints:
const BoxConstraints(maxWidth: 400),
child: Card(
child: Padding(
padding: const EdgeInsets.all(40),
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: [
SvgPicture.asset(
'assets/images/bms_logo.svg',
height: 72,
Center(
child: Column(
children: [
SvgPicture.asset(
'assets/images/bms_logo.svg',
height: 72,
),
const SizedBox(height: 16),
Text(
'Business Management System',
style: AppTextStyles.bodySmall
.copyWith(
color:
AppColors.textSecondary,
),
),
],
),
),
const SizedBox(height: 36),
TextFormField(
controller: _usernameController,
decoration: const InputDecoration(
labelText: 'Username',
prefixIcon:
Icon(Icons.person_outline),
),
textInputAction:
TextInputAction.next,
autofocus: true,
validator: (v) =>
(v == null ||
v.trim().isEmpty)
? 'Required'
: null,
),
const SizedBox(height: 16),
Text(
'Business Management System',
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.textSecondary,
TextFormField(
controller: _passwordController,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Password',
prefixIcon:
const Icon(Icons.lock_outline),
suffixIcon: IconButton(
icon: Icon(_obscurePassword
? Icons.visibility_off
: Icons.visibility),
onPressed: () => setState(() =>
_obscurePassword =
!_obscurePassword),
),
),
textInputAction:
TextInputAction.done,
onFieldSubmitted: (_) => _submit(),
validator: (v) =>
(v == null || v.isEmpty)
? 'Required'
: null,
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: authAsync.isLoading
? null
: _submit,
child: authAsync.isLoading
? const SizedBox.square(
dimension: 20,
child:
CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white),
)
: const Text('Sign In'),
),
],
),
),
const SizedBox(height: 36),
TextFormField(
controller: _usernameController,
decoration: const InputDecoration(
labelText: 'Username',
prefixIcon: Icon(Icons.person_outline),
),
textInputAction: TextInputAction.next,
autofocus: true,
validator: (v) =>
(v == null || v.trim().isEmpty)
? 'Required'
: null,
),
const SizedBox(height: 16),
TextFormField(
controller: _passwordController,
obscureText: _obscurePassword,
decoration: InputDecoration(
labelText: 'Password',
prefixIcon: const Icon(Icons.lock_outline),
suffixIcon: IconButton(
icon: Icon(_obscurePassword
? Icons.visibility_off
: Icons.visibility),
onPressed: () => setState(() =>
_obscurePassword = !_obscurePassword),
),
),
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) => _submit(),
validator: (v) =>
(v == null || v.isEmpty) ? 'Required' : null,
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: authAsync.isLoading ? null : _submit,
child: authAsync.isLoading
? const SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white),
)
: const Text('Sign In'),
),
],
),
),
),
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Text(
'© ${DateTime.now().year} BMS. All rights reserved.',
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.textDisabled,
fontSize: 11,
Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Text(
'© ${DateTime.now().year} BMS. All rights reserved.',
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.textDisabled,
fontSize: 11,
),
),
),
),
],
),
],
),
),
),
),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/icons/Icon-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/icons/Icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/icons/Icon-maskable-192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified web/icons/Icon-maskable-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified windows/runner/resources/app_icon.ico
Binary file not shown.