autofill attempt

This commit is contained in:
doman 2023-07-30 15:31:36 +02:00
parent cbcdf7418e
commit 64703dbc67
17 changed files with 72 additions and 47 deletions

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/screens/login.dart'; import 'package:fooder/screens/login.dart';
import 'package:fooder_web/client.dart'; import 'package:fooder/client.dart';
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {

View file

@ -1,4 +1,4 @@
import 'package:fooder_web/models/meal.dart'; import 'package:fooder/models/meal.dart';
class Diary { class Diary {

View file

@ -1,4 +1,4 @@
import 'package:fooder_web/models/product.dart'; import 'package:fooder/models/product.dart';
class Entry { class Entry {
final int id; final int id;

View file

@ -1,4 +1,4 @@
import 'package:fooder_web/models/entry.dart'; import 'package:fooder/models/entry.dart';
class Meal { class Meal {

View file

@ -1,11 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:fooder/screens/based.dart';
import 'package:fooder_web/models/product.dart'; import 'package:fooder/models/product.dart';
import 'package:fooder_web/models/diary.dart'; import 'package:fooder/models/diary.dart';
import 'package:fooder_web/models/meal.dart'; import 'package:fooder/models/meal.dart';
import 'package:fooder_web/widgets/product.dart'; import 'package:fooder/widgets/product.dart';
import 'package:fooder_web/screens/add_product.dart'; import 'package:fooder/screens/add_product.dart';
class AddEntryScreen extends BasedScreen { class AddEntryScreen extends BasedScreen {

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:fooder/screens/based.dart';
import 'package:fooder_web/models/diary.dart'; import 'package:fooder/models/diary.dart';
class AddMealScreen extends BasedScreen { class AddMealScreen extends BasedScreen {

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:fooder/screens/based.dart';
import 'package:fooder_web/models/product.dart'; import 'package:fooder/models/product.dart';
class AddProductScreen extends BasedScreen { class AddProductScreen extends BasedScreen {

View file

@ -1,5 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/client.dart'; import 'package:fooder/client.dart';
abstract class BasedScreen extends StatefulWidget { abstract class BasedScreen extends StatefulWidget {

View file

@ -1,10 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:fooder/screens/based.dart';
import 'package:fooder_web/models/product.dart'; import 'package:fooder/models/product.dart';
import 'package:fooder_web/models/entry.dart'; import 'package:fooder/models/entry.dart';
import 'package:fooder_web/widgets/product.dart'; import 'package:fooder/widgets/product.dart';
import 'package:fooder_web/screens/add_product.dart'; import 'package:fooder/screens/add_product.dart';
class EditEntryScreen extends BasedScreen { class EditEntryScreen extends BasedScreen {

View file

@ -1,7 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:flutter/services.dart';
import 'package:fooder_web/screens/main.dart'; import 'package:fooder/screens/based.dart';
import 'package:fooder_web/screens/register.dart'; import 'package:fooder/screens/main.dart';
import 'package:fooder/screens/register.dart';
class LoginScreen extends BasedScreen { class LoginScreen extends BasedScreen {
@ -69,6 +70,13 @@ class _LoginScreen extends State<LoginScreen> {
@override @override
void initState () { void initState () {
super.initState(); super.initState();
SystemChannels.textInput.invokeMethod('TextInput.setClientFeatures', <String, dynamic>{
'setAuthenticationConfiguration': true,
'setAutofillHints': <String>[
AutofillHints.username,
AutofillHints.password,
],
});
_asyncInitState().then((value) => null); _asyncInitState().then((value) => null);
} }
@ -105,6 +113,7 @@ class _LoginScreen extends State<LoginScreen> {
labelText: 'Username', labelText: 'Username',
), ),
controller: usernameController, controller: usernameController,
autofillHints: const [AutofillHints.username],
), ),
TextFormField( TextFormField(
obscureText: true, obscureText: true,
@ -112,7 +121,8 @@ class _LoginScreen extends State<LoginScreen> {
labelText: 'Password', labelText: 'Password',
), ),
controller: passwordController, controller: passwordController,
onFieldSubmitted: (_) => _login() onFieldSubmitted: (_) => _login(),
autofillHints: const [AutofillHints.password],
), ),
Padding( Padding(
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 10),

View file

@ -1,9 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:fooder/screens/based.dart';
import 'package:fooder_web/screens/login.dart'; import 'package:fooder/screens/login.dart';
import 'package:fooder_web/screens/add_entry.dart'; import 'package:fooder/screens/add_entry.dart';
import 'package:fooder_web/models/diary.dart'; import 'package:fooder/models/diary.dart';
import 'package:fooder_web/widgets/diary.dart'; import 'package:fooder/widgets/diary.dart';
class MainScreen extends BasedScreen { class MainScreen extends BasedScreen {

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/screens/based.dart'; import 'package:flutter/services.dart';
import 'package:fooder/screens/based.dart';
class RegisterScreen extends BasedScreen { class RegisterScreen extends BasedScreen {
@ -23,6 +24,18 @@ class _RegisterScreen extends State<RegisterScreen> {
super.dispose(); super.dispose();
} }
@override
void initState() {
super.initState();
SystemChannels.textInput.invokeMethod('TextInput.setClientFeatures', <String, dynamic>{
'setAuthenticationConfiguration': true,
'setAutofillHints': <String>[
AutofillHints.username,
AutofillHints.password,
],
});
}
void showError(String message) void showError(String message)
{ {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
@ -85,6 +98,7 @@ class _RegisterScreen extends State<RegisterScreen> {
labelText: 'Username', labelText: 'Username',
), ),
controller: usernameController, controller: usernameController,
autofillHints: const [AutofillHints.username],
), ),
TextFormField( TextFormField(
obscureText: true, obscureText: true,
@ -92,6 +106,7 @@ class _RegisterScreen extends State<RegisterScreen> {
labelText: 'Password', labelText: 'Password',
), ),
controller: passwordController, controller: passwordController,
autofillHints: const [AutofillHints.password],
), ),
TextFormField( TextFormField(
obscureText: true, obscureText: true,

View file

@ -1,9 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/models/diary.dart'; import 'package:fooder/models/diary.dart';
import 'package:fooder_web/widgets/meal.dart'; import 'package:fooder/widgets/meal.dart';
import 'package:fooder_web/widgets/macro.dart'; import 'package:fooder/widgets/macro.dart';
import 'package:fooder_web/client.dart'; import 'package:fooder/client.dart';
import 'package:fooder_web/screens/add_meal.dart'; import 'package:fooder/screens/add_meal.dart';
import 'dart:core'; import 'dart:core';

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/models/entry.dart'; import 'package:fooder/models/entry.dart';
import 'package:fooder_web/widgets/macro.dart'; import 'package:fooder/widgets/macro.dart';
import 'dart:core'; import 'dart:core';

View file

@ -1,9 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/models/meal.dart'; import 'package:fooder/models/meal.dart';
import 'package:fooder_web/widgets/entry.dart'; import 'package:fooder/widgets/entry.dart';
import 'package:fooder_web/widgets/macro.dart'; import 'package:fooder/widgets/macro.dart';
import 'package:fooder_web/screens/edit_entry.dart'; import 'package:fooder/screens/edit_entry.dart';
import 'package:fooder_web/client.dart'; import 'package:fooder/client.dart';
import 'dart:core'; import 'dart:core';

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fooder_web/models/product.dart'; import 'package:fooder/models/product.dart';
import 'package:fooder_web/widgets/macro.dart'; import 'package:fooder/widgets/macro.dart';
import 'dart:core'; import 'dart:core';

View file

@ -1,5 +1,5 @@
name: fooder_web name: fooder
description: A new Flutter project. description: FOODER - no bloat food diary
# The following line prevents the package from being accidentally published to # The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages. # pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev