mirror of
https://github.com/ErfanRht/MovieLab.git
synced 2026-03-13 10:23:24 +08:00
(add) guide-model-bottom-sheet in several app sections
This commit is contained in:
7
lib/modules/cache/cache_data.dart
vendored
7
lib/modules/cache/cache_data.dart
vendored
@@ -7,6 +7,8 @@ class CacheData extends GetxController {
|
||||
List<FullActor> actorsData = [];
|
||||
List<Map> companiesData = [];
|
||||
|
||||
bool updateNotice = false;
|
||||
|
||||
addShowData({required FullShow show}) {
|
||||
showsData.add(show);
|
||||
update();
|
||||
@@ -21,4 +23,9 @@ class CacheData extends GetxController {
|
||||
companiesData.add(company);
|
||||
update();
|
||||
}
|
||||
|
||||
updateNoticed() {
|
||||
updateNotice = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:movielab/models/hive/models/actor_preview.dart';
|
||||
import 'package:movielab/models/hive/models/show_preview.dart';
|
||||
import 'package:movielab/models/hive/models/user.dart';
|
||||
import 'package:movielab/models/item_models/actor_models/actor_preview_model.dart';
|
||||
import 'package:movielab/models/item_models/actor_models/full_actor_model.dart';
|
||||
import 'package:movielab/models/item_models/show_models/full_show_model.dart';
|
||||
import 'package:movielab/models/item_models/show_models/show_preview_model.dart';
|
||||
import 'package:movielab/models/user_model/user_model.dart';
|
||||
@@ -16,7 +15,12 @@ import 'package:movielab/pages/splash/get_user_data.dart';
|
||||
class PreferencesShareholder {
|
||||
// Delete all items of a list in the shared preferences
|
||||
Future<bool> deleteList(String listName) async {
|
||||
Box<HiveShowPreview> list = Hive.box<HiveShowPreview>(listName);
|
||||
late Box list;
|
||||
if (listName == "artists") {
|
||||
list = Hive.box<HiveActorPreview>(listName);
|
||||
} else {
|
||||
list = Hive.box<HiveShowPreview>(listName);
|
||||
}
|
||||
list.deleteAll(list.keys.toList());
|
||||
if (kDebugMode) {
|
||||
print("All items of $listName deleted");
|
||||
@@ -69,7 +73,7 @@ class PreferencesShareholder {
|
||||
|
||||
// Add an artist to the favourite artists list
|
||||
Future<bool> addArtistToFav({
|
||||
required FullActor actor,
|
||||
required dynamic actor,
|
||||
}) async {
|
||||
Box<HiveActorPreview> list = Hive.box<HiveActorPreview>('artists');
|
||||
list.add(convertFullActorToHive(actor: actor));
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:movielab/constants/app.dart';
|
||||
import 'package:movielab/constants/colors.dart';
|
||||
import 'package:movielab/models/hive/convertor.dart';
|
||||
import 'package:movielab/models/hive/models/show_preview.dart';
|
||||
import 'package:movielab/modules/cache/cache_data.dart';
|
||||
import 'package:movielab/modules/tools/system_ui_overlay_style.dart';
|
||||
import 'package:movielab/pages/main/main_controller.dart';
|
||||
import 'package:movielab/widgets/buttons/activeable_button.dart';
|
||||
@@ -34,7 +35,10 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
void initState() {
|
||||
super.initState();
|
||||
setSystemUIOverlayStyle();
|
||||
checkForUpdateDialog(context, this);
|
||||
if (!Get.find<CacheData>().updateNotice) {
|
||||
checkForUpdateDialog(context, this);
|
||||
Get.find<CacheData>().updateNoticed();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,23 +2,32 @@ import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:movielab/constants/colors.dart';
|
||||
import 'package:movielab/models/item_models/actor_models/actor_preview_model.dart';
|
||||
import 'package:movielab/models/item_models/show_models/show_preview_model.dart';
|
||||
import 'package:movielab/modules/preferences/preferences_shareholder.dart';
|
||||
import 'package:movielab/modules/tools/capitalizer.dart';
|
||||
import 'package:movielab/pages/main/profile/sections/list_page/sections/navbar.dart';
|
||||
import 'package:movielab/pages/shared/userlist_body.dart';
|
||||
import 'package:movielab/widgets/guide_modal.dart';
|
||||
import 'package:movielab/widgets/toast.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ListPage extends StatelessWidget {
|
||||
class ListPage extends StatefulWidget {
|
||||
final String listName;
|
||||
ListPage({Key? key, required this.listName}) : super(key: key);
|
||||
const ListPage({Key? key, required this.listName}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ListPage> createState() => _ListPageState();
|
||||
}
|
||||
|
||||
class _ListPageState extends State<ListPage> with TickerProviderStateMixin {
|
||||
late FToast fToast;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
fToast = FToast();
|
||||
|
||||
return Scaffold(
|
||||
floatingActionButton: listName == "recommendations"
|
||||
floatingActionButton: widget.listName == "recommendations"
|
||||
? const SizedBox.shrink()
|
||||
: Container(
|
||||
height: 55.0,
|
||||
@@ -27,45 +36,67 @@ class ListPage extends StatelessWidget {
|
||||
child: FittedBox(
|
||||
child: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
PreferencesShareholder preferencesShareholder =
|
||||
PreferencesShareholder();
|
||||
preferencesShareholder.deleteList(listName);
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
fToast.removeQueuedCustomToasts();
|
||||
fToast.showToast(
|
||||
child: ToastWidget(
|
||||
mainText: "The list is cleaned!",
|
||||
buttonText: "Undo",
|
||||
buttonColor: kPrimaryColor,
|
||||
buttonOnTap: () async {
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 75));
|
||||
PreferencesShareholder preferencesShareholder =
|
||||
PreferencesShareholder();
|
||||
List<ShowPreview> list =
|
||||
await preferencesShareholder.getList(
|
||||
listName: listName);
|
||||
for (ShowPreview show in list) {
|
||||
preferencesShareholder.addShowToList(
|
||||
showPreview: show,
|
||||
listName: listName,
|
||||
guideModalSheet(context,
|
||||
vsync: this,
|
||||
title: "Delete all the items",
|
||||
decription:
|
||||
"This will remove all saved items in your ${widget.listName.capitalize()}.",
|
||||
buttonText: "Delete All", onTap: () async {
|
||||
PreferencesShareholder preferencesShareholder =
|
||||
PreferencesShareholder();
|
||||
preferencesShareholder.deleteList(widget.listName);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 100));
|
||||
// ignore: use_build_context_synchronously
|
||||
Navigator.pop(context);
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 150));
|
||||
fToast.removeQueuedCustomToasts();
|
||||
fToast.showToast(
|
||||
child: ToastWidget(
|
||||
mainText: "The list is cleaned!",
|
||||
buttonText: "Undo",
|
||||
buttonColor: kPrimaryColor,
|
||||
buttonOnTap: () async {
|
||||
await Future.delayed(
|
||||
const Duration(milliseconds: 75));
|
||||
PreferencesShareholder
|
||||
preferencesShareholder =
|
||||
PreferencesShareholder();
|
||||
if (widget.listName == "artists") {
|
||||
List<ActorPreview> list =
|
||||
preferencesShareholder.getFavActors();
|
||||
for (ActorPreview item in list) {
|
||||
preferencesShareholder.addArtistToFav(
|
||||
actor: item);
|
||||
}
|
||||
} else {
|
||||
List<ShowPreview> list =
|
||||
preferencesShareholder.getList(
|
||||
listName: widget.listName);
|
||||
for (var item in list) {
|
||||
preferencesShareholder.addShowToList(
|
||||
showPreview: item,
|
||||
listName: widget.listName,
|
||||
);
|
||||
}
|
||||
}
|
||||
fToast.removeQueuedCustomToasts();
|
||||
fToast.showToast(
|
||||
child: ToastWidget(
|
||||
mainText: "List is restored!",
|
||||
buttonText: "Ok",
|
||||
buttonColor: kAccentColor,
|
||||
closeOnButtonTap: true,
|
||||
),
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: const Duration(seconds: 3),
|
||||
);
|
||||
}
|
||||
fToast.removeQueuedCustomToasts();
|
||||
fToast.showToast(
|
||||
child: ToastWidget(
|
||||
mainText: "List is restored!",
|
||||
buttonText: "Ok",
|
||||
buttonColor: kAccentColor,
|
||||
closeOnButtonTap: true,
|
||||
),
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: const Duration(seconds: 3),
|
||||
);
|
||||
}),
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: const Duration(seconds: 3),
|
||||
);
|
||||
}),
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: const Duration(seconds: 3),
|
||||
);
|
||||
});
|
||||
},
|
||||
tooltip: "Delete all",
|
||||
backgroundColor: Colors.white,
|
||||
@@ -75,7 +106,7 @@ class ListPage extends StatelessWidget {
|
||||
)),
|
||||
),
|
||||
),
|
||||
appBar: listPageNavbar(context, listName: listName),
|
||||
body: UserListBody(listName: listName));
|
||||
appBar: listPageNavbar(context, listName: widget.listName),
|
||||
body: UserListBody(listName: widget.listName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,22 +77,33 @@ class _BackupPageState extends State<BackupPage> with TickerProviderStateMixin {
|
||||
description:
|
||||
"Select the exported movielab-backup-date.db from file manager",
|
||||
onPressed: () async {
|
||||
await restoreBackup().then((final bool success) async {
|
||||
fToast.removeQueuedCustomToasts();
|
||||
fToast.showToast(
|
||||
child: ToastWidget(
|
||||
mainText: success
|
||||
? "The backup file imported successfully."
|
||||
: "There's a problem with the imported file!",
|
||||
mainTextColor: success ? Colors.green : kPrimaryColor,
|
||||
buttonText: "Ok",
|
||||
fontSize: 13,
|
||||
buttonColor: Colors.black,
|
||||
closeOnButtonTap: true,
|
||||
),
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: const Duration(seconds: 2),
|
||||
);
|
||||
guideModalSheet(context,
|
||||
height: 290,
|
||||
vsync: this,
|
||||
title: "Select Backup File",
|
||||
decription:
|
||||
"Select the backup file from your storage, and be aware that your current account info will be replaced by this file content.",
|
||||
buttonText: "Select File", onTap: () async {
|
||||
await restoreBackup().then((final bool success) async {
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
Navigator.pop(context);
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
fToast.removeQueuedCustomToasts();
|
||||
fToast.showToast(
|
||||
child: ToastWidget(
|
||||
mainText: success
|
||||
? "The backup file imported successfully."
|
||||
: "There's a problem with the imported file!",
|
||||
mainTextColor: success ? Colors.green : kPrimaryColor,
|
||||
buttonText: "Ok",
|
||||
fontSize: 13,
|
||||
buttonColor: Colors.black,
|
||||
closeOnButtonTap: true,
|
||||
),
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: const Duration(seconds: 2),
|
||||
);
|
||||
});
|
||||
});
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -48,7 +48,7 @@ class _SettingsPageState extends State<SettingsPage>
|
||||
title: "Clear media content cache",
|
||||
decription:
|
||||
"This will remove all cached content like images, trailers, etc., and wouldn't hurt your personal data.",
|
||||
buttonText: "Clear cache", onTap: () async {
|
||||
buttonText: "Clear Cache", onTap: () async {
|
||||
await DefaultCacheManager().emptyCache();
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
Navigator.pop(context);
|
||||
|
||||
Reference in New Issue
Block a user