mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-09 08:08:14 -06:00
Fixed visual bugs, added notifications on document upload success, enabled editing in inbox, added hints
This commit is contained in:
@@ -17,6 +17,20 @@ class ServerAddressFormField extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ServerAddressFormFieldState extends State<ServerAddressFormField> {
|
||||
bool _canClear = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_textEditingController.addListener(() {
|
||||
if (_textEditingController.text.isNotEmpty) {
|
||||
setState(() {
|
||||
_canClear = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final TextEditingController _textEditingController = TextEditingController();
|
||||
|
||||
@override
|
||||
@@ -25,12 +39,30 @@ class _ServerAddressFormFieldState extends State<ServerAddressFormField> {
|
||||
key: const ValueKey('login-server-address'),
|
||||
controller: _textEditingController,
|
||||
name: ServerAddressFormField.fkServerAddress,
|
||||
validator: FormBuilderValidators.required(
|
||||
errorText: S.of(context).loginPageServerUrlValidatorMessageRequiredText,
|
||||
),
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: FormBuilderValidators.compose([
|
||||
FormBuilderValidators.required(
|
||||
errorText:
|
||||
S.of(context).loginPageServerUrlValidatorMessageRequiredText,
|
||||
),
|
||||
FormBuilderValidators.match(
|
||||
r"https?://.*",
|
||||
errorText:
|
||||
S.of(context).loginPageServerUrlValidatorMessageMissingSchemeText,
|
||||
)
|
||||
]),
|
||||
decoration: InputDecoration(
|
||||
hintText: "http://192.168.1.50:8000",
|
||||
labelText: S.of(context).loginPageServerUrlFieldLabel,
|
||||
suffixIcon: _canClear
|
||||
? IconButton(
|
||||
icon: Icon(Icons.clear),
|
||||
color: Theme.of(context).iconTheme.color,
|
||||
onPressed: () {
|
||||
_textEditingController.clear();
|
||||
},
|
||||
)
|
||||
: null,
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
if (value == null) return;
|
||||
|
||||
@@ -24,28 +24,38 @@ class ServerConnectionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ServerConnectionPageState extends State<ServerConnectionPage> {
|
||||
bool _isCheckingConnection = false;
|
||||
ReachabilityStatus _reachabilityStatus = ReachabilityStatus.unknown;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
toolbarHeight: kToolbarHeight - 4,
|
||||
title: Text(S.of(context).loginPageTitle),
|
||||
bottom: PreferredSize(
|
||||
child: _isCheckingConnection
|
||||
? const LinearProgressIndicator()
|
||||
: const SizedBox(height: 4.0),
|
||||
preferredSize: const Size.fromHeight(4.0),
|
||||
),
|
||||
),
|
||||
resizeToAvoidBottomInset: true,
|
||||
body: Column(
|
||||
children: [
|
||||
ServerAddressFormField(
|
||||
onDone: (address) {
|
||||
_updateReachability();
|
||||
},
|
||||
).padded(),
|
||||
ClientCertificateFormField(
|
||||
onChanged: (_) => _updateReachability(),
|
||||
).padded(),
|
||||
_buildStatusIndicator(),
|
||||
],
|
||||
).padded(),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ServerAddressFormField(
|
||||
onDone: (address) {
|
||||
_updateReachability(address);
|
||||
},
|
||||
).padded(),
|
||||
ClientCertificateFormField(
|
||||
onChanged: (_) => _updateReachability(),
|
||||
).padded(),
|
||||
_buildStatusIndicator(),
|
||||
],
|
||||
).padded(),
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
@@ -62,20 +72,30 @@ class _ServerConnectionPageState extends State<ServerConnectionPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _updateReachability() async {
|
||||
Future<void> _updateReachability([String? address]) async {
|
||||
setState(() {
|
||||
_isCheckingConnection = true;
|
||||
});
|
||||
final status = await context
|
||||
.read<ConnectivityStatusService>()
|
||||
.isPaperlessServerReachable(
|
||||
widget.formBuilderKey.currentState!
|
||||
.getRawValue(ServerAddressFormField.fkServerAddress),
|
||||
address ??
|
||||
widget.formBuilderKey.currentState!
|
||||
.getRawValue(ServerAddressFormField.fkServerAddress),
|
||||
widget.formBuilderKey.currentState?.getRawValue(
|
||||
ClientCertificateFormField.fkClientCertificate,
|
||||
),
|
||||
);
|
||||
setState(() => _reachabilityStatus = status);
|
||||
setState(() {
|
||||
_isCheckingConnection = false;
|
||||
_reachabilityStatus = status;
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildStatusIndicator() {
|
||||
if (_isCheckingConnection) {
|
||||
return const ListTile();
|
||||
}
|
||||
Color errorColor = Theme.of(context).colorScheme.error;
|
||||
switch (_reachabilityStatus) {
|
||||
case ReachabilityStatus.unknown:
|
||||
@@ -112,6 +132,12 @@ class _ServerConnectionPageState extends State<ServerConnectionPage> {
|
||||
.loginPageReachabilityInvalidClientCertificateConfigurationText,
|
||||
errorColor,
|
||||
);
|
||||
case ReachabilityStatus.connectionTimeout:
|
||||
return _buildIconText(
|
||||
Icons.close,
|
||||
S.of(context).loginPageReachabilityConnectionTimeoutText,
|
||||
errorColor,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user