NOTIFICATION RUN
This commit is contained in:
		
							parent
							
								
									fcbb12266b
								
							
						
					
					
						commit
						4ad5c408c4
					
				
					 2 changed files with 36 additions and 7 deletions
				
			
		| 
						 | 
					@ -72,7 +72,7 @@ class ApiClient {
 | 
				
			||||||
    return jsonDecode(response.body);
 | 
					    return jsonDecode(response.body);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void login(String username, String password) async {
 | 
					  Future<void> login(String username, String password) async {
 | 
				
			||||||
    final headers = {
 | 
					    final headers = {
 | 
				
			||||||
      'Content-Type': 'application/x-www-form-urlencoded',
 | 
					      'Content-Type': 'application/x-www-form-urlencoded',
 | 
				
			||||||
      'Accept': 'application/json',
 | 
					      'Accept': 'application/json',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,13 +21,42 @@ class _LoginScreen extends State<LoginScreen> {
 | 
				
			||||||
    super.dispose();
 | 
					    super.dispose();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void showError(String message)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ScaffoldMessenger.of(context).showSnackBar(
 | 
				
			||||||
 | 
					      SnackBar(
 | 
				
			||||||
 | 
					        content: Text(message, textAlign: TextAlign.center),
 | 
				
			||||||
 | 
					        backgroundColor: Theme.of(context).colorScheme.error,
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void showText(String text)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ScaffoldMessenger.of(context).showSnackBar(
 | 
				
			||||||
 | 
					      SnackBar(
 | 
				
			||||||
 | 
					        content: Text(text, textAlign: TextAlign.center),
 | 
				
			||||||
 | 
					        backgroundColor: Theme.of(context).colorScheme.primary,
 | 
				
			||||||
 | 
					      ),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void popMeDady() {
 | 
				
			||||||
 | 
					    Navigator.pop(context);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // login client when button pressed
 | 
					  // login client when button pressed
 | 
				
			||||||
  void _login() async {
 | 
					  void _login() async {
 | 
				
			||||||
    widget.apiClient.login(
 | 
					    try {
 | 
				
			||||||
 | 
					      await widget.apiClient.login(
 | 
				
			||||||
        usernameController.text,
 | 
					        usernameController.text,
 | 
				
			||||||
        passwordController.text,
 | 
					        passwordController.text,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    Navigator.pop(context);
 | 
					      showText("Logged in");
 | 
				
			||||||
 | 
					      popMeDady();
 | 
				
			||||||
 | 
					    } on Exception catch (e) {
 | 
				
			||||||
 | 
					      showError(e.toString());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
| 
						 | 
					@ -35,7 +64,7 @@ class _LoginScreen extends State<LoginScreen> {
 | 
				
			||||||
    return Scaffold(
 | 
					    return Scaffold(
 | 
				
			||||||
      appBar: AppBar(
 | 
					      appBar: AppBar(
 | 
				
			||||||
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
 | 
					        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
 | 
				
			||||||
        title: const Text("ANALUJ"),
 | 
					        title: const Text("FOODER login"),
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
      body: Center(
 | 
					      body: Center(
 | 
				
			||||||
        child: Container(
 | 
					        child: Container(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue