mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-30 20:24:25 +00:00
refactor: remove riverpod state management
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/// This file is deprecated and should no longer be actively used.
|
||||
/// All imports should happen directly and canonical export files will not be used anymore.
|
||||
|
||||
export 'state/state.dart';
|
||||
export 'system/state.dart';
|
||||
export 'types/loading_state.dart';
|
||||
export 'database/box.dart';
|
||||
export 'database/models/profile.dart';
|
||||
|
||||
@@ -17,7 +17,7 @@ import 'package:lunasea/modules/sabnzbd.dart';
|
||||
import 'package:lunasea/modules/nzbget.dart';
|
||||
import 'package:lunasea/modules/tautulli.dart';
|
||||
|
||||
import 'package:lunasea/modules/dashboard/core/state.dart' as dashboard_state;
|
||||
import 'package:lunasea/modules/dashboard/core/state.dart';
|
||||
import 'package:lunasea/api/wake_on_lan/wake_on_lan.dart';
|
||||
import 'package:lunasea/system/flavor.dart';
|
||||
|
||||
@@ -484,7 +484,7 @@ extension LunaModuleExtension on LunaModule {
|
||||
case LunaModule.WAKE_ON_LAN:
|
||||
return null;
|
||||
case LunaModule.DASHBOARD:
|
||||
return context.read<dashboard_state.ModuleState>();
|
||||
return context.read<DashboardState>();
|
||||
case LunaModule.SETTINGS:
|
||||
return context.read<SettingsState>();
|
||||
case LunaModule.SEARCH:
|
||||
|
||||
@@ -4,11 +4,11 @@ import 'package:lunasea/modules/dashboard/core/adapters/calendar_starting_size.d
|
||||
import 'package:lunasea/modules/dashboard/core/adapters/calendar_starting_type.dart';
|
||||
import 'package:lunasea/modules/dashboard/core/api/api.dart';
|
||||
import 'package:lunasea/modules/dashboard/core/api/data/abstract.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
|
||||
class ModuleState extends LunaModuleState {
|
||||
ModuleState() {
|
||||
class DashboardState extends LunaModuleState {
|
||||
DashboardState() {
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:lunasea/widgets/ui.dart';
|
||||
import 'package:lunasea/system/logger.dart';
|
||||
@@ -26,8 +25,8 @@ class _State extends State<CalendarPage>
|
||||
|
||||
@override
|
||||
Future<void> loadCallback() async {
|
||||
context.read<ModuleState>().resetToday();
|
||||
context.read<ModuleState>().resetUpcoming();
|
||||
context.read<DashboardState>().resetToday();
|
||||
context.read<DashboardState>().resetUpcoming();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -38,7 +37,7 @@ class _State extends State<CalendarPage>
|
||||
key: _refreshKey,
|
||||
onRefresh: loadCallback,
|
||||
child: FutureBuilder(
|
||||
future: context.watch<ModuleState>().upcoming,
|
||||
future: context.watch<DashboardState>().upcoming,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
AsyncSnapshot<Map<DateTime, List<CalendarData>>> snapshot,
|
||||
@@ -55,7 +54,7 @@ class _State extends State<CalendarPage>
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
final events = snapshot.data!;
|
||||
return Selector<ModuleState, CalendarStartingType>(
|
||||
return Selector<DashboardState, CalendarStartingType>(
|
||||
selector: (_, s) => s.calendarType,
|
||||
builder: (context, type, _) {
|
||||
if (type == CalendarStartingType.CALENDAR)
|
||||
|
||||
@@ -44,7 +44,7 @@ class _State extends State<CalendarView> {
|
||||
|
||||
void _onDaySelected(DateTime selected, DateTime focused) {
|
||||
HapticFeedback.selectionClick();
|
||||
context.read<ModuleState>().selected = selected.floor();
|
||||
context.read<DashboardState>().selected = selected.floor();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -108,10 +108,10 @@ class _State extends State<CalendarView> {
|
||||
DashboardDatabase.CALENDAR_STARTING_SIZE,
|
||||
],
|
||||
builder: (context, _) {
|
||||
DateTime firstDay = context.watch<ModuleState>().today.subtract(
|
||||
DateTime firstDay = context.watch<DashboardState>().today.subtract(
|
||||
Duration(days: DashboardDatabase.CALENDAR_DAYS_PAST.read()),
|
||||
);
|
||||
DateTime lastDay = context.watch<ModuleState>().today.add(
|
||||
DateTime lastDay = context.watch<DashboardState>().today.add(
|
||||
Duration(days: DashboardDatabase.CALENDAR_DAYS_FUTURE.read()),
|
||||
);
|
||||
return SafeArea(
|
||||
@@ -124,7 +124,7 @@ class _State extends State<CalendarView> {
|
||||
),
|
||||
rowHeight: 48.0,
|
||||
rangeSelectionMode: RangeSelectionMode.disabled,
|
||||
focusedDay: context.watch<ModuleState>().selected,
|
||||
focusedDay: context.watch<DashboardState>().selected,
|
||||
firstDay: firstDay,
|
||||
lastDay: lastDay,
|
||||
//events: widget.events,
|
||||
@@ -142,7 +142,8 @@ class _State extends State<CalendarView> {
|
||||
startingDayOfWeek:
|
||||
DashboardDatabase.CALENDAR_STARTING_DAY.read().data,
|
||||
selectedDayPredicate: (date) {
|
||||
return date.floor() == context.read<ModuleState>().selected;
|
||||
return date.floor() ==
|
||||
context.read<DashboardState>().selected;
|
||||
},
|
||||
calendarStyle: CalendarStyle(
|
||||
markersMaxCount: 1,
|
||||
@@ -170,7 +171,7 @@ class _State extends State<CalendarView> {
|
||||
todayTextStyle: dayStyle,
|
||||
),
|
||||
onFormatChanged: (format) {
|
||||
context.read<ModuleState>().calendarFormat = format;
|
||||
context.read<DashboardState>().calendarFormat = format;
|
||||
},
|
||||
daysOfWeekStyle: DaysOfWeekStyle(
|
||||
weekendStyle: weekdayStyle,
|
||||
@@ -180,7 +181,7 @@ class _State extends State<CalendarView> {
|
||||
if (widget.events.isEmpty) return [];
|
||||
return widget.events[date.floor()] ?? [];
|
||||
},
|
||||
calendarFormat: context.watch<ModuleState>().calendarFormat,
|
||||
calendarFormat: context.watch<DashboardState>().calendarFormat,
|
||||
availableCalendarFormats: const {
|
||||
CalendarFormat.month: 'Month',
|
||||
CalendarFormat.twoWeeks: '2 Weeks',
|
||||
@@ -228,7 +229,7 @@ class _State extends State<CalendarView> {
|
||||
}
|
||||
|
||||
Widget _calendarList() {
|
||||
final selected = context.read<ModuleState>().selected;
|
||||
final selected = context.read<DashboardState>().selected;
|
||||
final events = widget.events[selected.floor()] ?? [];
|
||||
if (events.isEmpty) {
|
||||
return Expanded(
|
||||
|
||||
@@ -62,7 +62,7 @@ class _State extends State<ScheduleView> {
|
||||
keys.sort();
|
||||
|
||||
for (final key in keys) {
|
||||
final selected = context.read<ModuleState>().selected;
|
||||
final selected = context.read<DashboardState>().selected;
|
||||
if (key.isBefore(selected) || key.isAtSameMomentAs(selected)) {
|
||||
offsetOfSelected = offset;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:lunasea/widgets/ui.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
@@ -44,14 +43,14 @@ class _State extends State<SwitchViewAction> with LunaLoadCallbackMixin {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Selector<ModuleState, CalendarStartingType>(
|
||||
return Selector<DashboardState, CalendarStartingType>(
|
||||
selector: (_, state) => state.calendarType,
|
||||
builder: (context, view, _) {
|
||||
if (_showButton) {
|
||||
return LunaIconButton.appBar(
|
||||
icon: view.icon,
|
||||
onPressed: () {
|
||||
final state = context.read<ModuleState>();
|
||||
final state = context.read<DashboardState>();
|
||||
if (view == CalendarStartingType.CALENDAR)
|
||||
state.calendarType = CalendarStartingType.SCHEDULE;
|
||||
else
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:lunasea/database/tables/lunasea.dart';
|
||||
import 'package:lunasea/firebase/types.dart';
|
||||
import 'package:lunasea/modules.dart';
|
||||
import 'package:lunasea/modules/settings/core/types/header.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
import 'package:lunasea/system/localization.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
import 'package:lunasea/widgets/ui.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:lunasea/core.dart';
|
||||
import 'package:lunasea/firebase/auth.dart';
|
||||
import 'package:lunasea/utils/validator.dart';
|
||||
|
||||
class AccountPasswordResetRoute extends ConsumerStatefulWidget {
|
||||
class AccountPasswordResetRoute extends StatefulWidget {
|
||||
const AccountPasswordResetRoute({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
@@ -12,7 +12,7 @@ class AccountPasswordResetRoute extends ConsumerStatefulWidget {
|
||||
_State createState() => _State();
|
||||
}
|
||||
|
||||
class _State extends ConsumerState<AccountPasswordResetRoute>
|
||||
class _State extends State<AccountPasswordResetRoute>
|
||||
with LunaScrollControllerMixin {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
@@ -99,7 +99,7 @@ class _State extends ConsumerState<AccountPasswordResetRoute>
|
||||
}
|
||||
|
||||
bool _validateEmailAddress({bool showSnackBarOnFailure = true}) {
|
||||
if (!ref.watch(validatorProvider).email(_emailController.text)) {
|
||||
if (!LunaValidator().email(_emailController.text)) {
|
||||
if (showSnackBarOnFailure) {
|
||||
showLunaErrorSnackBar(
|
||||
title: 'settings.InvalidEmail'.tr(),
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:lunasea/firebase/auth.dart';
|
||||
import 'package:lunasea/router/routes/settings.dart';
|
||||
import 'package:lunasea/utils/validator.dart';
|
||||
|
||||
class SettingsAccountSignedOutPage extends ConsumerStatefulWidget {
|
||||
class SettingsAccountSignedOutPage extends StatefulWidget {
|
||||
final ScrollController scrollController;
|
||||
|
||||
const SettingsAccountSignedOutPage({
|
||||
@@ -16,7 +16,7 @@ class SettingsAccountSignedOutPage extends ConsumerStatefulWidget {
|
||||
_State createState() => _State();
|
||||
}
|
||||
|
||||
class _State extends ConsumerState<SettingsAccountSignedOutPage> {
|
||||
class _State extends State<SettingsAccountSignedOutPage> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final TextEditingController _emailController = TextEditingController();
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
@@ -124,7 +124,7 @@ class _State extends ConsumerState<SettingsAccountSignedOutPage> {
|
||||
}
|
||||
|
||||
bool _validateEmailAddress({bool showSnackBarOnFailure = true}) {
|
||||
if (!ref.watch(validatorProvider).email(_emailController.text)) {
|
||||
if (!LunaValidator().email(_emailController.text)) {
|
||||
if (showSnackBarOnFailure)
|
||||
showLunaErrorSnackBar(
|
||||
title: 'settings.InvalidEmail'.tr(),
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:lunasea/modules/settings.dart';
|
||||
import 'package:lunasea/utils/encryption.dart';
|
||||
import 'package:lunasea/utils/uuid.dart';
|
||||
|
||||
class SettingsAccountBackupConfigurationTile extends ConsumerStatefulWidget {
|
||||
class SettingsAccountBackupConfigurationTile extends StatefulWidget {
|
||||
const SettingsAccountBackupConfigurationTile({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
@@ -16,7 +16,7 @@ class SettingsAccountBackupConfigurationTile extends ConsumerStatefulWidget {
|
||||
_State createState() => _State();
|
||||
}
|
||||
|
||||
class _State extends ConsumerState<SettingsAccountBackupConfigurationTile> {
|
||||
class _State extends State<SettingsAccountBackupConfigurationTile> {
|
||||
LunaLoadingState _loadingState = LunaLoadingState.INACTIVE;
|
||||
|
||||
void updateState(LunaLoadingState state) {
|
||||
@@ -44,12 +44,10 @@ class _State extends ConsumerState<SettingsAccountBackupConfigurationTile> {
|
||||
Tuple2<bool, String> _values =
|
||||
await SettingsDialogs().backupConfiguration(context);
|
||||
if (_values.item1) {
|
||||
final encryption = ref.watch(encryptionProvider);
|
||||
|
||||
String decrypted = LunaConfig().export();
|
||||
String encrypted = encryption.encrypt(_values.item2, decrypted);
|
||||
String encrypted = LunaEncryption().encrypt(_values.item2, decrypted);
|
||||
int timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
String id = ref.watch(uuidProvider).generate();
|
||||
String id = LunaUUID().generate();
|
||||
String format = 'MMMM dd, yyyy\nhh:mm:ss a';
|
||||
String title = DateFormat(format).format(DateTime.now());
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:lunasea/firebase/storage.dart';
|
||||
import 'package:lunasea/modules/settings.dart';
|
||||
import 'package:lunasea/utils/encryption.dart';
|
||||
|
||||
class SettingsAccountRestoreConfigurationTile extends ConsumerStatefulWidget {
|
||||
class SettingsAccountRestoreConfigurationTile extends StatefulWidget {
|
||||
const SettingsAccountRestoreConfigurationTile({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
@@ -15,7 +15,7 @@ class SettingsAccountRestoreConfigurationTile extends ConsumerStatefulWidget {
|
||||
_State createState() => _State();
|
||||
}
|
||||
|
||||
class _State extends ConsumerState<SettingsAccountRestoreConfigurationTile> {
|
||||
class _State extends State<SettingsAccountRestoreConfigurationTile> {
|
||||
LunaLoadingState _loadingState = LunaLoadingState.INACTIVE;
|
||||
|
||||
void updateState(LunaLoadingState state) {
|
||||
@@ -61,8 +61,7 @@ class _State extends ConsumerState<SettingsAccountRestoreConfigurationTile> {
|
||||
Tuple2<bool, String> _key = await SettingsDialogs().decryptBackup(context);
|
||||
if (_key.item1) {
|
||||
try {
|
||||
final encryption = ref.watch(encryptionProvider);
|
||||
String decrypted = encryption.decrypt(_key.item2, encrypted);
|
||||
String decrypted = LunaEncryption().decrypt(_key.item2, encrypted);
|
||||
await LunaConfig().import(context, decrypted);
|
||||
showLunaSuccessSnackBar(
|
||||
title: 'settings.RestoreFromCloudSuccess'.tr(),
|
||||
|
||||
@@ -5,28 +5,27 @@ import 'package:lunasea/modules/settings.dart';
|
||||
import 'package:lunasea/system/filesystem/filesystem.dart';
|
||||
import 'package:lunasea/utils/encryption.dart';
|
||||
|
||||
class SettingsSystemBackupRestoreBackupTile extends ConsumerWidget {
|
||||
class SettingsSystemBackupRestoreBackupTile extends StatelessWidget {
|
||||
const SettingsSystemBackupRestoreBackupTile({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
Widget build(BuildContext context) {
|
||||
return LunaBlock(
|
||||
title: 'settings.BackupToDevice'.tr(),
|
||||
body: [TextSpan(text: 'settings.BackupToDeviceDescription'.tr())],
|
||||
trailing: const LunaIconButton(icon: Icons.upload_rounded),
|
||||
onTap: () async => _backup(context, ref),
|
||||
onTap: () async => _backup(context),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _backup(BuildContext context, WidgetRef ref) async {
|
||||
Future<void> _backup(BuildContext context) async {
|
||||
try {
|
||||
final _values = await SettingsDialogs().backupConfiguration(context);
|
||||
if (_values.item1) {
|
||||
final encryption = ref.watch(encryptionProvider);
|
||||
String data = LunaConfig().export();
|
||||
String encrypted = encryption.encrypt(_values.item2, data);
|
||||
String encrypted = LunaEncryption().encrypt(_values.item2, data);
|
||||
String name = DateFormat('y-MM-dd kk-mm-ss').format(DateTime.now());
|
||||
bool result = await LunaFileSystem().save(
|
||||
context,
|
||||
|
||||
@@ -8,14 +8,14 @@ import 'package:lunasea/vendor.dart';
|
||||
import 'package:lunasea/widgets/sheets/changelog/sheet.dart';
|
||||
import 'package:lunasea/widgets/ui.dart';
|
||||
|
||||
class BuildDetails extends ConsumerStatefulWidget {
|
||||
class BuildDetails extends StatefulWidget {
|
||||
const BuildDetails({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
ConsumerState<BuildDetails> createState() => _State();
|
||||
State<BuildDetails> createState() => _State();
|
||||
}
|
||||
|
||||
class _State extends ConsumerState<BuildDetails> {
|
||||
class _State extends State<BuildDetails> {
|
||||
Future<PackageInfo> packageInfo = PackageInfo.fromPlatform();
|
||||
Future<Tuple2<bool, int?>> checkUpdates = LunaBuild().isLatestBuildNumber();
|
||||
|
||||
|
||||
@@ -6,25 +6,25 @@ import 'package:lunasea/system/filesystem/file.dart';
|
||||
import 'package:lunasea/system/filesystem/filesystem.dart';
|
||||
import 'package:lunasea/utils/encryption.dart';
|
||||
|
||||
class SettingsSystemBackupRestoreRestoreTile extends ConsumerWidget {
|
||||
class SettingsSystemBackupRestoreRestoreTile extends StatelessWidget {
|
||||
const SettingsSystemBackupRestoreRestoreTile({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
Widget build(BuildContext context) {
|
||||
return LunaBlock(
|
||||
title: 'settings.RestoreFromDevice'.tr(),
|
||||
body: [TextSpan(text: 'settings.RestoreFromDeviceDescription'.tr())],
|
||||
trailing: const LunaIconButton(icon: Icons.download_rounded),
|
||||
onTap: () async => _restore(context, ref),
|
||||
onTap: () async => _restore(context),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _restore(BuildContext context, WidgetRef ref) async {
|
||||
Future<void> _restore(BuildContext context) async {
|
||||
try {
|
||||
LunaFile? file = await LunaFileSystem().read(context, ['lunasea']);
|
||||
if (file != null) await _decryptBackup(context, ref, file);
|
||||
if (file != null) await _decryptBackup(context, file);
|
||||
} catch (error, stack) {
|
||||
LunaLogger().error('Failed to restore device backup', error, stack);
|
||||
showLunaErrorSnackBar(
|
||||
@@ -36,15 +36,13 @@ class SettingsSystemBackupRestoreRestoreTile extends ConsumerWidget {
|
||||
|
||||
Future<void> _decryptBackup(
|
||||
BuildContext context,
|
||||
WidgetRef ref,
|
||||
LunaFile file,
|
||||
) async {
|
||||
Tuple2<bool, String> _key = await SettingsDialogs().decryptBackup(context);
|
||||
if (_key.item1) {
|
||||
final encryption = ref.watch(encryptionProvider);
|
||||
String encrypted = String.fromCharCodes(file.data);
|
||||
try {
|
||||
String decrypted = encryption.decrypt(_key.item2, encrypted);
|
||||
String decrypted = LunaEncryption().decrypt(_key.item2, encrypted);
|
||||
await LunaConfig().import(context, decrypted);
|
||||
showLunaSuccessSnackBar(
|
||||
title: 'settings.RestoreFromCloudSuccess'.tr(),
|
||||
@@ -56,7 +54,7 @@ class SettingsSystemBackupRestoreRestoreTile extends ConsumerWidget {
|
||||
message: 'lunasea.IncorrectEncryptionKey'.tr(),
|
||||
showButton: true,
|
||||
buttonText: 'lunasea.Retry'.tr(),
|
||||
buttonOnPressed: () async => _decryptBackup(context, ref, file),
|
||||
buttonOnPressed: () async => _decryptBackup(context, file),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import 'package:lunasea/api/sabnzbd/api.dart';
|
||||
import 'package:lunasea/database/box.dart';
|
||||
import 'package:lunasea/state/sabnzbd/config.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
|
||||
final apiProvider =
|
||||
Provider.autoDispose.family<SABnzbdAPI, String>((ref, uuid) {
|
||||
final db = ref.watch(configProvider(uuid));
|
||||
|
||||
// A database update was triggered
|
||||
if (db.hasValue) {
|
||||
final config = db.value!;
|
||||
return SABnzbdAPI(
|
||||
host: config.host,
|
||||
apiKey: config.apiKey,
|
||||
headers: config.headers,
|
||||
);
|
||||
}
|
||||
|
||||
// Initial load
|
||||
final config = LunaBox.profiles.read(uuid)!;
|
||||
return SABnzbdAPI(
|
||||
host: config.sabnzbdHost,
|
||||
apiKey: config.sabnzbdKey,
|
||||
headers: config.sabnzbdHeaders,
|
||||
);
|
||||
});
|
||||
@@ -1,32 +0,0 @@
|
||||
import 'package:lunasea/database/box.dart';
|
||||
import 'package:lunasea/database/models/profile.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
|
||||
class _DB {
|
||||
final bool enabled;
|
||||
final String host;
|
||||
final String apiKey;
|
||||
final Map<String, String> headers;
|
||||
|
||||
_DB(
|
||||
this.enabled, {
|
||||
this.host = '',
|
||||
this.apiKey = '',
|
||||
this.headers = const {},
|
||||
});
|
||||
}
|
||||
|
||||
final configProvider = StreamProvider.family<_DB, String>((ref, uuid) async* {
|
||||
final box = LunaBox.profiles.watch(uuid);
|
||||
await for (final event in box) {
|
||||
if (event.deleted) yield _DB(false);
|
||||
|
||||
LunaProfile profile = event.value;
|
||||
yield _DB(
|
||||
profile.sabnzbdEnabled,
|
||||
host: profile.sabnzbdHost,
|
||||
apiKey: profile.sabnzbdKey,
|
||||
headers: profile.sabnzbdHeaders,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
|
||||
import 'package:lunasea/system/flavor.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:lunasea/modules/dashboard/core/state.dart' as dashboard;
|
||||
import 'package:lunasea/modules/dashboard/core/state.dart';
|
||||
import 'package:lunasea/modules/lidarr/core/state.dart';
|
||||
import 'package:lunasea/modules/radarr/core/state.dart';
|
||||
import 'package:lunasea/modules/search/core/state.dart';
|
||||
@@ -12,9 +12,7 @@ import 'package:lunasea/modules/nzbget/core/state.dart';
|
||||
import 'package:lunasea/modules/tautulli/core/state.dart';
|
||||
import 'package:lunasea/modules.dart';
|
||||
import 'package:lunasea/router/router.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart' show ProviderScope;
|
||||
|
||||
class LunaState {
|
||||
LunaState._();
|
||||
@@ -27,23 +25,21 @@ class LunaState {
|
||||
LunaModule.values.forEach((module) => module.state(ctx)?.reset());
|
||||
}
|
||||
|
||||
static ProviderScope providers({required Widget child}) {
|
||||
return ProviderScope(
|
||||
child: MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => dashboard.ModuleState()),
|
||||
ChangeNotifierProvider(create: (_) => SettingsState()),
|
||||
ChangeNotifierProvider(create: (_) => SearchState()),
|
||||
ChangeNotifierProvider(create: (_) => LidarrState()),
|
||||
ChangeNotifierProvider(create: (_) => RadarrState()),
|
||||
ChangeNotifierProvider(create: (_) => SonarrState()),
|
||||
ChangeNotifierProvider(create: (_) => NZBGetState()),
|
||||
ChangeNotifierProvider(create: (_) => SABnzbdState()),
|
||||
ChangeNotifierProvider(create: (_) => OverseerrState()),
|
||||
ChangeNotifierProvider(create: (_) => TautulliState()),
|
||||
],
|
||||
child: child,
|
||||
),
|
||||
static MultiProvider providers({required Widget child}) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => DashboardState()),
|
||||
ChangeNotifierProvider(create: (_) => SettingsState()),
|
||||
ChangeNotifierProvider(create: (_) => SearchState()),
|
||||
ChangeNotifierProvider(create: (_) => LidarrState()),
|
||||
ChangeNotifierProvider(create: (_) => RadarrState()),
|
||||
ChangeNotifierProvider(create: (_) => SonarrState()),
|
||||
ChangeNotifierProvider(create: (_) => NZBGetState()),
|
||||
ChangeNotifierProvider(create: (_) => SABnzbdState()),
|
||||
ChangeNotifierProvider(create: (_) => OverseerrState()),
|
||||
ChangeNotifierProvider(create: (_) => TautulliState()),
|
||||
],
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
import 'package:encrypt/encrypt.dart';
|
||||
|
||||
import 'package:lunasea/system/logger.dart';
|
||||
import 'package:lunasea/vendor.dart';
|
||||
|
||||
class LunaEncryption {
|
||||
const LunaEncryption._();
|
||||
|
||||
Key _generateKey(String key) {
|
||||
const _length = 32;
|
||||
const _pad = '0';
|
||||
@@ -40,5 +36,3 @@ class LunaEncryption {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final encryptionProvider = Provider((_) => const LunaEncryption._());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:lunasea/database/models/profile.dart';
|
||||
import 'package:lunasea/database/box.dart';
|
||||
import 'package:lunasea/database/tables/lunasea.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
import 'package:lunasea/router/router.dart';
|
||||
import 'package:lunasea/system/logger.dart';
|
||||
import 'package:lunasea/types/exception.dart';
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import 'package:lunasea/vendor.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class LunaUUID {
|
||||
const LunaUUID._();
|
||||
final Uuid _generator = const Uuid();
|
||||
static const Uuid _generator = Uuid();
|
||||
|
||||
String generate() {
|
||||
return _generator.v4();
|
||||
}
|
||||
}
|
||||
|
||||
final uuidProvider = Provider((_) => const LunaUUID._());
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import 'package:lunasea/vendor.dart';
|
||||
|
||||
class LunaValidator {
|
||||
const LunaValidator._();
|
||||
|
||||
bool email(String email) {
|
||||
const regex = r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)";
|
||||
return RegExp(regex).hasMatch(email);
|
||||
}
|
||||
}
|
||||
|
||||
final validatorProvider = Provider((_) => const LunaValidator._());
|
||||
|
||||
@@ -8,7 +8,6 @@ export 'package:dio/dio.dart';
|
||||
export 'package:easy_localization/easy_localization.dart';
|
||||
export 'package:expandable/expandable.dart';
|
||||
export 'package:flash/flash.dart';
|
||||
export 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
export 'package:go_router/go_router.dart';
|
||||
export 'package:hive/hive.dart';
|
||||
export 'package:hive_flutter/hive_flutter.dart';
|
||||
@@ -16,7 +15,7 @@ export 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
export 'package:json_annotation/json_annotation.dart';
|
||||
export 'package:meta/meta.dart';
|
||||
export 'package:package_info_plus/package_info_plus.dart';
|
||||
export 'package:provider/provider.dart' show ReadContext, WatchContext;
|
||||
export 'package:provider/provider.dart';
|
||||
export 'package:retrofit/retrofit.dart' hide Headers;
|
||||
export 'package:stash/stash_api.dart';
|
||||
export 'package:stash_memory/stash_memory.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
import 'package:lunasea/extensions/string/string.dart';
|
||||
import 'package:lunasea/system/build.dart';
|
||||
import 'package:lunasea/system/environment.dart';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
import 'package:lunasea/widgets/ui.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:lunasea/state/state.dart';
|
||||
import 'package:lunasea/system/state.dart';
|
||||
import 'package:lunasea/types/loading_state.dart';
|
||||
import 'package:lunasea/widgets/ui.dart';
|
||||
|
||||
|
||||
24
pubspec.lock
24
pubspec.lock
@@ -579,14 +579,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.9"
|
||||
flutter_riverpod:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_riverpod
|
||||
sha256: b3c3a8a9714b7f88dd2a41e1efbc47f76d620b06ab427c62ae7bc82298cd7dbb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
flutter_spinkit:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1109,14 +1101,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.0+1"
|
||||
riverpod:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: riverpod
|
||||
sha256: b0fbf7927333c5c318f7e2c22c8b4fd2542ba294de0373e80ecdb34e0dcd8dc4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1338,14 +1322,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.5.2"
|
||||
state_notifier:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: state_notifier
|
||||
sha256: "8fe42610f179b843b12371e40db58c9444f8757f8b69d181c97e50787caed289"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.2+1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -28,7 +28,6 @@ dependencies:
|
||||
fl_chart: ^0.61.0
|
||||
flash: ^2.0.5+1
|
||||
flutter_cache_manager: ^3.3.0
|
||||
flutter_riverpod: ^2.3.2
|
||||
flutter_spinkit: ^5.1.0
|
||||
go_router: ^6.5.0
|
||||
google_fonts: ^4.0.3
|
||||
|
||||
Reference in New Issue
Block a user