Add Supa account and search changes
This commit is contained in:
@@ -22,6 +22,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import 'package:weblibre/features/settings/presentation/widgets/settings_detail.dart';
|
||||
import 'package:weblibre/features/user/data/models/engine_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/engine_settings.dart';
|
||||
import 'package:weblibre/utils/exit_app.dart';
|
||||
@@ -57,95 +58,141 @@ class AddonCollectionScreen extends HookConsumerWidget {
|
||||
keys: [addonCollectionSetting],
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Custom Extension Collection'),
|
||||
actions: [
|
||||
if (addonCollectionSetting != null)
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
await ref
|
||||
.read(engineSettingsRepositoryProvider.notifier)
|
||||
.updateSettings(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.addonCollection(null),
|
||||
);
|
||||
return SettingsCustomScrollScaffold(
|
||||
title: 'Custom Extension Collection',
|
||||
actions: [
|
||||
if (addonCollectionSetting != null)
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
await ref
|
||||
.read(engineSettingsRepositoryProvider.notifier)
|
||||
.updateSettings(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.addonCollection(null),
|
||||
);
|
||||
|
||||
await exitApp(ref.container);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Form(
|
||||
key: formKey,
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: ListView(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: serverURLController,
|
||||
decoration: const InputDecoration(
|
||||
label: Text('Server URL'),
|
||||
hintText: _defaultServerUrl,
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
validator: (value) {
|
||||
return validateUrl(
|
||||
value,
|
||||
onlyHttpProtocol: true,
|
||||
eagerParsing: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: collectionUserController,
|
||||
decoration: const InputDecoration(
|
||||
label: Text('Collection User'),
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
),
|
||||
validator: validateRequired,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: collectionNameController,
|
||||
decoration: const InputDecoration(
|
||||
label: Text('Collection Name'),
|
||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
),
|
||||
validator: validateRequired,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState?.validate() == true) {
|
||||
await ref
|
||||
.read(engineSettingsRepositoryProvider.notifier)
|
||||
.updateSettings(
|
||||
(
|
||||
currentSettings,
|
||||
) => currentSettings.copyWith.addonCollection(
|
||||
AddonCollection(
|
||||
serverURL: serverURLController.text,
|
||||
collectionUser: collectionUserController.text,
|
||||
collectionName: collectionNameController.text,
|
||||
await exitApp(ref.container);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
],
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 20),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Form(
|
||||
key: formKey,
|
||||
child: SettingsSectionList(
|
||||
sections: [
|
||||
SettingsSectionDefinition(
|
||||
title: 'Collection Source',
|
||||
entries: [
|
||||
SettingsEntryDefinition(
|
||||
title: 'Collection configuration',
|
||||
subtitle:
|
||||
'Mozilla server, collection owner, and collection name',
|
||||
keywords: const ['addons', 'collection'],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: serverURLController,
|
||||
decoration: const InputDecoration(
|
||||
label: Text('Server URL'),
|
||||
hintText: _defaultServerUrl,
|
||||
floatingLabelBehavior:
|
||||
FloatingLabelBehavior.always,
|
||||
),
|
||||
keyboardType: TextInputType.url,
|
||||
validator: (value) {
|
||||
return validateUrl(
|
||||
value,
|
||||
onlyHttpProtocol: true,
|
||||
eagerParsing: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: collectionUserController,
|
||||
decoration: const InputDecoration(
|
||||
label: Text('Collection User'),
|
||||
floatingLabelBehavior:
|
||||
FloatingLabelBehavior.always,
|
||||
),
|
||||
validator: validateRequired,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: collectionNameController,
|
||||
decoration: const InputDecoration(
|
||||
label: Text('Collection Name'),
|
||||
floatingLabelBehavior:
|
||||
FloatingLabelBehavior.always,
|
||||
),
|
||||
validator: validateRequired,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SettingsSectionDefinition(
|
||||
title: 'Actions',
|
||||
entries: [
|
||||
SettingsEntryDefinition(
|
||||
title: 'Save & Restart Browser',
|
||||
subtitle:
|
||||
'Apply the custom collection and restart the browser',
|
||||
keywords: const ['restart'],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (formKey.currentState?.validate() == true) {
|
||||
await ref
|
||||
.read(
|
||||
engineSettingsRepositoryProvider
|
||||
.notifier,
|
||||
)
|
||||
.updateSettings(
|
||||
(currentSettings) => currentSettings
|
||||
.copyWith
|
||||
.addonCollection(
|
||||
AddonCollection(
|
||||
serverURL:
|
||||
serverURLController.text,
|
||||
collectionUser:
|
||||
collectionUserController
|
||||
.text,
|
||||
collectionName:
|
||||
collectionNameController
|
||||
.text,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await exitApp(ref.container);
|
||||
}
|
||||
},
|
||||
child: const Text('Save & Restart Browser'),
|
||||
),
|
||||
],
|
||||
await exitApp(ref.container);
|
||||
}
|
||||
},
|
||||
child: const Text('Save & Restart Browser'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
query: '',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user