update
This commit is contained in:
parent
f0d6bca4f3
commit
3aa12bfcad
135 changed files with 19410 additions and 112 deletions
|
|
@ -24,9 +24,9 @@ class AuthGate extends StatelessWidget {
|
|||
final session = snapshot.hasData ? snapshot.data!.session : null;
|
||||
|
||||
if (session != null) {
|
||||
return MainPage();
|
||||
return const MainPage();
|
||||
} else {
|
||||
return IndexPage();
|
||||
return const IndexPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_gate.dart';
|
||||
import 'package:pharmacy_mobile/pages/add_category.dart';
|
||||
import 'package:pharmacy_mobile/pages/add_generics.dart';
|
||||
import 'package:pharmacy_mobile/pages/add_medicine.dart';
|
||||
import 'package:pharmacy_mobile/pages/add_stock.dart';
|
||||
import 'package:pharmacy_mobile/pages/add_type.dart';
|
||||
import 'package:pharmacy_mobile/pages/delete_stock.dart';
|
||||
// import 'package:pharmacy_mobile/auth/auth_gate.dart';
|
||||
import 'package:pharmacy_mobile/pages/index_page.dart';
|
||||
import 'package:pharmacy_mobile/pages/list_stocks.dart';
|
||||
import 'package:pharmacy_mobile/pages/login_page.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
|
@ -14,10 +13,6 @@ import 'package:pharmacy_mobile/pages/main_page.dart';
|
|||
import 'package:pharmacy_mobile/pages/register_page.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
// void main() {
|
||||
// runApp(const MyApp());
|
||||
// }
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
|
|
@ -39,57 +34,57 @@ final _router = GoRouter(
|
|||
GoRoute(
|
||||
name: 'index',
|
||||
path: '/',
|
||||
builder: (context, state) => IndexPage(),
|
||||
builder: (context, state) => const AuthGate(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'login',
|
||||
path: '/login',
|
||||
builder: (context, state) => LoginPage(),
|
||||
builder: (context, state) => const LoginPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'register',
|
||||
path: '/register',
|
||||
builder: (context, state) => RegisterPage(),
|
||||
builder: (context, state) => const RegisterPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'main',
|
||||
path: '/main',
|
||||
builder: (context, state) => MainPage(),
|
||||
builder: (context, state) => const MainPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'addmedicines',
|
||||
path: '/addmedicines',
|
||||
builder: (context, state) => AddMedicinePage(),
|
||||
builder: (context, state) => const AddMedicinePage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'addgenerics',
|
||||
path: '/addgenerics',
|
||||
builder: (context, state) => AddGenericsPage(),
|
||||
builder: (context, state) => const AddGenericsPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'addtype',
|
||||
path: '/addtype',
|
||||
builder: (context, state) => AddTypePage(),
|
||||
builder: (context, state) => const AddTypePage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'addcategory',
|
||||
path: '/addcategory',
|
||||
builder: (context, state) => AddCategoryPage(),
|
||||
builder: (context, state) => const AddCategoryPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'addstock',
|
||||
path: '/addstock',
|
||||
builder: (context, state) => AddStockPage(),
|
||||
builder: (context, state) => const AddStockPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'liststocks',
|
||||
path: '/liststocks',
|
||||
builder: (context, state) => ListStocksPage(),
|
||||
builder: (context, state) => const ListStocksPage(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'deletestock',
|
||||
path: '/deletestock',
|
||||
builder: (context, state) => DeleteStockPage(),
|
||||
builder: (context, state) => const DeleteStockPage(),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -27,15 +27,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||
|
||||
bool _isLoading = false;
|
||||
|
||||
void checkLoggedIn() async {
|
||||
final user = _authService.getCurrentUser();
|
||||
if (user == null) {
|
||||
context.push('/');
|
||||
} else {
|
||||
context.push('/main');
|
||||
}
|
||||
}
|
||||
|
||||
void _signIn() async {
|
||||
// if (_isLoading) return;
|
||||
|
||||
|
|
@ -102,12 +93,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
checkLoggedIn();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
|
|
@ -174,6 +159,25 @@ class _LoginPageState extends State<LoginPage> {
|
|||
)),
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: "Don't have an account?",
|
||||
size: 14,
|
||||
),
|
||||
const Gap(8),
|
||||
GestureDetector(
|
||||
onTap: () => {context.push('/register')},
|
||||
child: const TextWidget(
|
||||
text: 'Register here',
|
||||
size: 14,
|
||||
underlined: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -25,21 +25,6 @@ class _MainPageState extends State<MainPage> {
|
|||
await _authService.signOut().then((_) => {context.go('/'), showNotification(context, 'Logged Out', true)});
|
||||
}
|
||||
|
||||
void checkLoggedIn() async {
|
||||
final user = _authService.getCurrentUser();
|
||||
if (user == null) {
|
||||
if (mounted) {
|
||||
context.push('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
checkLoggedIn();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/input_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/snackbar_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
const RegisterPage({super.key});
|
||||
|
|
@ -28,23 +31,49 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
final password = _passwordController.text;
|
||||
final confirmPassword = _confirmPasswordController.text;
|
||||
|
||||
try {
|
||||
await _authService.signUp(email, password);
|
||||
} catch (e) {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
if (email.isEmpty) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
|
||||
showNotification(context, 'Error: Please enter a valid email', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Please enter a password', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirmPassword.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: Please confirm password', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (password != confirmPassword) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Password does not match!')));
|
||||
showNotification(context, 'Password does not match!', false);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (mounted) {
|
||||
// context.showSnackBar('Check your email for a login link!');
|
||||
|
||||
// _emailController.clear();
|
||||
// }
|
||||
try {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
await _authService.signUp(email, password);
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: No Internet Connection', false);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: $e', false);
|
||||
}
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -112,6 +141,25 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
)),
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: "Already have an account?",
|
||||
size: 14,
|
||||
),
|
||||
const Gap(8),
|
||||
GestureDetector(
|
||||
onTap: () => {context.push('/login')},
|
||||
child: const TextWidget(
|
||||
text: 'Login here',
|
||||
size: 14,
|
||||
underlined: true,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
|
|
|
|||
|
|
@ -7,16 +7,19 @@ class TextWidget extends StatelessWidget {
|
|||
final double? opacity;
|
||||
final bool? bold;
|
||||
final bool? footer;
|
||||
final bool? underlined;
|
||||
|
||||
const TextWidget({super.key, required this.text, this.size, this.opacity, this.bold, this.footer});
|
||||
const TextWidget({super.key, required this.text, this.size, this.opacity, this.bold, this.footer, this.underlined});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textStyle = TextStyle(
|
||||
color: Color.fromRGBO(255, 255, 255, opacity ?? 1),
|
||||
fontSize: size ?? 28,
|
||||
fontWeight: bold == true ? FontWeight.bold : FontWeight.normal,
|
||||
);
|
||||
color: Color.fromRGBO(255, 255, 255, opacity ?? 1),
|
||||
fontSize: size ?? 28,
|
||||
fontWeight: bold == true ? FontWeight.bold : FontWeight.normal,
|
||||
decoration: underlined == true ? TextDecoration.underline : TextDecoration.none,
|
||||
decorationColor: const Color.fromRGBO(255, 255, 255, 1),
|
||||
decorationThickness: 2);
|
||||
|
||||
return footer == true
|
||||
? Text(text, style: GoogleFonts.inter(textStyle: textStyle))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue