mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-22 06:59:21 +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) {
|
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(
|
return SafeArea(
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
||||||
|
@ -89,7 +107,8 @@ class _SignInState extends State<SignIn> {
|
||||||
const Icon(Icons.help_outline, size: 16),
|
const Icon(Icons.help_outline, size: 16),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(L10n.global().signIn2faHintText),
|
child:
|
||||||
|
Text(L10n.global().signIn2faHintText),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -116,7 +135,8 @@ class _SignInState extends State<SignIn> {
|
||||||
Container(),
|
Container(),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState?.validate() == true) {
|
if (_formKey.currentState?.validate() ==
|
||||||
|
true) {
|
||||||
_connect();
|
_connect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -135,6 +155,7 @@ class _SignInState extends State<SignIn> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildForm(BuildContext context) {
|
Widget _buildForm(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
|
@ -256,9 +277,26 @@ class _SignInState extends State<SignIn> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// we've got a good account
|
// 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>();
|
final c = KiwiContainer().resolve<DiContainer>();
|
||||||
await c.sqliteDb.use((db) async {
|
await c.sqliteDb.use((db) async {
|
||||||
await db.insertAccountOf(account!);
|
await db.insertAccountOf(account);
|
||||||
});
|
});
|
||||||
// only signing in with app password would trigger distinct
|
// only signing in with app password would trigger distinct
|
||||||
final accounts = (Pref().getAccounts3Or([])..add(account)).distinct();
|
final accounts = (Pref().getAccounts3Or([])..add(account)).distinct();
|
||||||
|
@ -272,12 +310,11 @@ class _SignInState extends State<SignIn> {
|
||||||
Pref()
|
Pref()
|
||||||
..setAccounts3(accounts)
|
..setAccounts3(accounts)
|
||||||
..setCurrentAccountIndex(accounts.indexOf(account));
|
..setCurrentAccountIndex(accounts.indexOf(account));
|
||||||
Navigator.pushNamedAndRemoveUntil(context, Home.routeName, (route) => false,
|
|
||||||
arguments: HomeArguments(account));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
var _scheme = _Scheme.https;
|
var _scheme = _Scheme.https;
|
||||||
|
var _isConnecting = false;
|
||||||
|
|
||||||
final _formValue = _FormValue();
|
final _formValue = _FormValue();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue