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,100 +40,121 @@ class _SignInState extends State<SignIn> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context) {
|
||||||
return SafeArea(
|
if (_isConnecting) {
|
||||||
child: LayoutBuilder(
|
return Stack(
|
||||||
builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
children: const [
|
||||||
return Form(
|
Positioned(
|
||||||
key: _formKey,
|
left: 0,
|
||||||
child: SingleChildScrollView(
|
right: 0,
|
||||||
child: ConstrainedBox(
|
bottom: 64,
|
||||||
constraints: BoxConstraints(
|
child: Center(
|
||||||
minHeight: viewportConstraints.maxHeight,
|
child: SizedBox(
|
||||||
),
|
width: 24,
|
||||||
child: IntrinsicHeight(
|
height: 24,
|
||||||
child: Column(
|
child: CircularProgressIndicator(),
|
||||||
children: [
|
),
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.all(24),
|
),
|
||||||
child: Text(
|
],
|
||||||
L10n.global().signInHeaderText,
|
);
|
||||||
style: Theme.of(context).textTheme.headline5,
|
} else {
|
||||||
textAlign: TextAlign.center,
|
return SafeArea(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (BuildContext context, BoxConstraints viewportConstraints) {
|
||||||
|
return Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
minHeight: viewportConstraints.maxHeight,
|
||||||
|
),
|
||||||
|
child: IntrinsicHeight(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Text(
|
||||||
|
L10n.global().signInHeaderText,
|
||||||
|
style: Theme.of(context).textTheme.headline5,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Align(
|
||||||
Align(
|
alignment: Alignment.center,
|
||||||
alignment: Alignment.center,
|
child: Container(
|
||||||
child: Container(
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: AppTheme.widthLimitedContentMaxWidth),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||||
|
child: _buildForm(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
maxWidth: AppTheme.widthLimitedContentMaxWidth),
|
maxWidth: AppTheme.widthLimitedContentMaxWidth),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: _buildForm(context),
|
child: InkWell(
|
||||||
),
|
onTap: () {
|
||||||
),
|
launch(help_utils.twoFactorAuthUrl);
|
||||||
Container(
|
},
|
||||||
alignment: AlignmentDirectional.centerStart,
|
child: Padding(
|
||||||
constraints: const BoxConstraints(
|
padding: const EdgeInsets.symmetric(
|
||||||
maxWidth: AppTheme.widthLimitedContentMaxWidth),
|
horizontal: 16, vertical: 16),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
child: Row(
|
||||||
child: InkWell(
|
mainAxisSize: MainAxisSize.max,
|
||||||
onTap: () {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
launch(help_utils.twoFactorAuthUrl);
|
children: [
|
||||||
},
|
const Icon(Icons.help_outline, size: 16),
|
||||||
child: Padding(
|
const SizedBox(width: 4),
|
||||||
padding: const EdgeInsets.symmetric(
|
Expanded(
|
||||||
horizontal: 16, vertical: 16),
|
child:
|
||||||
child: Row(
|
Text(L10n.global().signIn2faHintText),
|
||||||
mainAxisSize: MainAxisSize.max,
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
],
|
||||||
children: [
|
),
|
||||||
const Icon(Icons.help_outline, size: 16),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Expanded(
|
|
||||||
child: Text(L10n.global().signIn2faHintText),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (!platform_k.isWeb) Expanded(child: Container()),
|
||||||
if (!platform_k.isWeb) Expanded(child: Container()),
|
Container(
|
||||||
Container(
|
constraints: const BoxConstraints(
|
||||||
constraints: const BoxConstraints(
|
maxWidth: AppTheme.widthLimitedContentMaxWidth),
|
||||||
maxWidth: AppTheme.widthLimitedContentMaxWidth),
|
padding: const EdgeInsets.all(16),
|
||||||
padding: const EdgeInsets.all(16),
|
child: Row(
|
||||||
child: Row(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
children: [
|
||||||
children: [
|
if (!ModalRoute.of(context)!.isFirst)
|
||||||
if (!ModalRoute.of(context)!.isFirst)
|
TextButton(
|
||||||
TextButton(
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Text(MaterialLocalizations.of(context)
|
||||||
|
.cancelButtonLabel),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Container(),
|
||||||
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
if (_formKey.currentState?.validate() ==
|
||||||
|
true) {
|
||||||
|
_connect();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(MaterialLocalizations.of(context)
|
child: Text(L10n.global().connectButtonLabel),
|
||||||
.cancelButtonLabel),
|
),
|
||||||
)
|
],
|
||||||
else
|
),
|
||||||
Container(),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (_formKey.currentState?.validate() == true) {
|
|
||||||
_connect();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(L10n.global().connectButtonLabel),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildForm(BuildContext context) {
|
Widget _buildForm(BuildContext context) {
|
||||||
|
@ -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