mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-23 23:44:44 +01:00
Hide sign in details while connecting
This commit is contained in:
parent
1737025570
commit
e72dc82a1b
1 changed files with 122 additions and 85 deletions
|
@ -40,6 +40,24 @@ class _SignInState extends State<SignIn> {
|
|||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
if (_isConnecting) {
|
||||
return Stack(
|
||||
children: const [
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 64,
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return SafeArea(
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
||||
|
@ -89,7 +107,8 @@ class _SignInState extends State<SignIn> {
|
|||
const Icon(Icons.help_outline, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(L10n.global().signIn2faHintText),
|
||||
child:
|
||||
Text(L10n.global().signIn2faHintText),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -116,7 +135,8 @@ class _SignInState extends State<SignIn> {
|
|||
Container(),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState?.validate() == true) {
|
||||
if (_formKey.currentState?.validate() ==
|
||||
true) {
|
||||
_connect();
|
||||
}
|
||||
},
|
||||
|
@ -135,6 +155,7 @@ class _SignInState extends State<SignIn> {
|
|||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildForm(BuildContext context) {
|
||||
return Column(
|
||||
|
@ -256,9 +277,26 @@ class _SignInState extends State<SignIn> {
|
|||
return;
|
||||
}
|
||||
// we've got a good account
|
||||
setState(() {
|
||||
_isConnecting = true;
|
||||
});
|
||||
try {
|
||||
await _persistAccount(account);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, Home.routeName, (route) => false,
|
||||
arguments: HomeArguments(account));
|
||||
} catch (_) {
|
||||
setState(() {
|
||||
_isConnecting = false;
|
||||
});
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _persistAccount(Account account) async {
|
||||
final c = KiwiContainer().resolve<DiContainer>();
|
||||
await c.sqliteDb.use((db) async {
|
||||
await db.insertAccountOf(account!);
|
||||
await db.insertAccountOf(account);
|
||||
});
|
||||
// only signing in with app password would trigger distinct
|
||||
final accounts = (Pref().getAccounts3Or([])..add(account)).distinct();
|
||||
|
@ -272,12 +310,11 @@ class _SignInState extends State<SignIn> {
|
|||
Pref()
|
||||
..setAccounts3(accounts)
|
||||
..setCurrentAccountIndex(accounts.indexOf(account));
|
||||
Navigator.pushNamedAndRemoveUntil(context, Home.routeName, (route) => false,
|
||||
arguments: HomeArguments(account));
|
||||
}
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
var _scheme = _Scheme.https;
|
||||
var _isConnecting = false;
|
||||
|
||||
final _formValue = _FormValue();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue