chore: run dart format
Some checks are pending
Flutter CI & Release / Test (push) Waiting to run
Flutter CI & Release / Build Android APKs (push) Blocked by required conditions
Flutter CI & Release / build_linux (push) Blocked by required conditions
Flutter CI & Release / Create GitHub Release (push) Blocked by required conditions

This commit is contained in:
Dr.Blank 2026-01-10 16:51:05 +05:30
parent a520136e01
commit e23c0b6c5f
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
84 changed files with 1565 additions and 1945 deletions

View file

@ -22,11 +22,7 @@ import 'package:vaani/settings/api_settings_provider.dart'
import 'package:vaani/settings/models/models.dart' as model;
class UserLoginWidget extends HookConsumerWidget {
const UserLoginWidget({
super.key,
required this.server,
this.onSuccess,
});
const UserLoginWidget({super.key, required this.server, this.onSuccess});
final Uri server;
final Function(model.AuthenticatedUser)? onSuccess;
@ -34,8 +30,9 @@ class UserLoginWidget extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final serverStatusError = useMemoized(() => ErrorResponseHandler(), []);
final serverStatus =
ref.watch(serverStatusProvider(server, serverStatusError.storeError));
final serverStatus = ref.watch(
serverStatusProvider(server, serverStatusError.storeError),
);
return serverStatus.when(
data: (value) {
@ -55,9 +52,7 @@ class UserLoginWidget extends HookConsumerWidget {
);
},
loading: () {
return const Center(
child: CircularProgressIndicator(),
);
return const Center(child: CircularProgressIndicator());
},
error: (error, _) {
return Center(
@ -68,10 +63,7 @@ class UserLoginWidget extends HookConsumerWidget {
ElevatedButton(
onPressed: () {
ref.invalidate(
serverStatusProvider(
server,
serverStatusError.storeError,
),
serverStatusProvider(server, serverStatusError.storeError),
);
},
child: const Text('Try again'),
@ -84,11 +76,7 @@ class UserLoginWidget extends HookConsumerWidget {
}
}
enum AuthMethodChoice {
local,
openid,
authToken,
}
enum AuthMethodChoice { local, openid, authToken }
class UserLoginMultipleAuth extends HookConsumerWidget {
const UserLoginMultipleAuth({
@ -117,21 +105,17 @@ class UserLoginMultipleAuth extends HookConsumerWidget {
);
model.AudiobookShelfServer addServer() {
var newServer = model.AudiobookShelfServer(
serverUrl: server,
);
var newServer = model.AudiobookShelfServer(serverUrl: server);
try {
// add the server to the list of servers
ref.read(audiobookShelfServerProvider.notifier).addServer(
newServer,
);
ref.read(audiobookShelfServerProvider.notifier).addServer(newServer);
} on ServerAlreadyExistsException catch (e) {
newServer = e.server;
} finally {
ref.read(apiSettingsProvider.notifier).updateState(
ref.read(apiSettingsProvider).copyWith(
activeServer: newServer,
),
ref
.read(apiSettingsProvider.notifier)
.updateState(
ref.read(apiSettingsProvider).copyWith(activeServer: newServer),
);
}
return newServer;
@ -150,42 +134,49 @@ class UserLoginMultipleAuth extends HookConsumerWidget {
runAlignment: WrapAlignment.center,
runSpacing: 10,
alignment: WrapAlignment.center,
children: [
// a small label to show the user what to do
if (localAvailable)
ChoiceChip(
label: const Text('Local'),
selected: methodChoice.value == AuthMethodChoice.local,
onSelected: (selected) {
if (selected) {
methodChoice.value = AuthMethodChoice.local;
}
},
),
if (openIDAvailable)
ChoiceChip(
label: const Text('OpenID'),
selected: methodChoice.value == AuthMethodChoice.openid,
onSelected: (selected) {
if (selected) {
methodChoice.value = AuthMethodChoice.openid;
}
},
),
ChoiceChip(
label: const Text('Token'),
selected:
methodChoice.value == AuthMethodChoice.authToken,
onSelected: (selected) {
if (selected) {
methodChoice.value = AuthMethodChoice.authToken;
}
},
),
].animate(interval: 100.ms).fadeIn(
duration: 150.ms,
curve: Curves.easeIn,
),
children:
[
// a small label to show the user what to do
if (localAvailable)
ChoiceChip(
label: const Text('Local'),
selected:
methodChoice.value ==
AuthMethodChoice.local,
onSelected: (selected) {
if (selected) {
methodChoice.value = AuthMethodChoice.local;
}
},
),
if (openIDAvailable)
ChoiceChip(
label: const Text('OpenID'),
selected:
methodChoice.value ==
AuthMethodChoice.openid,
onSelected: (selected) {
if (selected) {
methodChoice.value =
AuthMethodChoice.openid;
}
},
),
ChoiceChip(
label: const Text('Token'),
selected:
methodChoice.value ==
AuthMethodChoice.authToken,
onSelected: (selected) {
if (selected) {
methodChoice.value =
AuthMethodChoice.authToken;
}
},
),
]
.animate(interval: 100.ms)
.fadeIn(duration: 150.ms, curve: Curves.easeIn),
),
),
Padding(
@ -195,21 +186,21 @@ class UserLoginMultipleAuth extends HookConsumerWidget {
transitionBuilder: fadeSlideTransitionBuilder,
child: switch (methodChoice.value) {
AuthMethodChoice.authToken => UserLoginWithToken(
server: server,
addServer: addServer,
onSuccess: onSuccess,
),
server: server,
addServer: addServer,
onSuccess: onSuccess,
),
AuthMethodChoice.local => UserLoginWithPassword(
server: server,
addServer: addServer,
onSuccess: onSuccess,
),
server: server,
addServer: addServer,
onSuccess: onSuccess,
),
AuthMethodChoice.openid => UserLoginWithOpenID(
server: server,
addServer: addServer,
openIDButtonText: openIDButtonText,
onSuccess: onSuccess,
),
server: server,
addServer: addServer,
openIDButtonText: openIDButtonText,
onSuccess: onSuccess,
),
},
),
),