No time to commit.. My people need me!

This commit is contained in:
Erfan Rahmati
2022-07-05 12:39:57 +04:30
parent 7617ccba4b
commit 97f060af66
23 changed files with 639 additions and 185 deletions

View File

@@ -2,7 +2,9 @@ import 'dart:ui';
const kBackgroundColor = Color(0xff191A32);
const kPrimaryColor = Color(0xffE11A38);
const kSecondaryColor = Color(0xffE6B91E);
const kSecondaryColor = Color(0xff132d4e);
const kAccentColor = Color(0xff00bfff);
const kImdbColor = Color(0xffE6B91E);
const kGreyColor = Color(0xffA2A2A5);
const kBlueColor = Color(0xff162C5D);
const kLightBlueColor = Color(0xff00bfff);

View File

@@ -1,6 +1,8 @@
// ignore_for_file: constant_identifier_names
enum SystemUIOverlayStyle { DARK, LIGHT, RED }
enum ImdbList { TOP_250_MOVIES, TOP_250_TVS, BoxOffice, AllTimeBoxOffice }
enum RequestResult {
NOT_STARTED,
LOADING,
@@ -9,3 +11,12 @@ enum RequestResult {
FAILURE_USER_PROBLEM,
FAILURE_SERVER_PROBLEM
}
enum ListName {
WATCHLIST,
HISTORY,
COLLECTION,
FAVORITE_ARTISTS,
FAVORITE_TRAILERS,
PERSONAL_LIST
}

View File

@@ -19,7 +19,13 @@ void main() async {
// Initialize Hive and Hive Flutter
await Hive.initFlutter();
registerAdapters();
Hive.openBox<HiveShowPreview>('bookmarks');
Hive.openBox<HiveShowPreview>('collection');
Hive.openBox<HiveShowPreview>('watchlist');
Hive.openBox<HiveShowPreview>('history');
Hive.openBox<HiveShowPreview>('collection');
Hive.openBox<HiveShowPreview>('favorite_artists');
Hive.openBox<HiveShowPreview>('favorite_trailers');
Hive.openBox<HiveShowPreview>('personal_lists');
// Initialize the controllers
Get.put(MainController());

View File

@@ -1,5 +1,3 @@
class HiveTypes {
static const int searchResult = 0;
static const int showPreview = 1;
static const int preferencesShareholder = 2;
static const int showPreview = 0;
}

View File

@@ -6,7 +6,6 @@ import 'package:movielab/constants/types.dart';
import 'package:movielab/modules/cache/cacheholder.dart';
import 'package:movielab/pages/main/home/home_data_controller.dart';
import 'package:movielab/pages/main/search/search_bar/search_bar_controller.dart';
import '../models/actor_models/full_actor_model.dart';
import '../models/episode_model.dart';
import '../models/search_result_model.dart';
@@ -16,8 +15,8 @@ import '../models/show_models/show_preview_model.dart';
class APIRequester {
static const String imdbBaseUrl = 'https://imdb-api.com/en/API';
// API keys to access the IMDB API:
static const String apiKey = "k_6lgd4s89";
// static const String apiKey = "k_y9zcdoq3";
// static const String apiKey = "k_6lgd4s89";
static const String apiKey = "k_y9zcdoq3";
// static const String apiKey = "";
// Get recently popular movies from the IMDB API

View File

@@ -5,35 +5,37 @@ import '../models/hive/models/show_preview.dart';
import '../models/show_models/full_show_model.dart';
class PreferencesShareholder {
// Delete all bookmarks from the shared preferences
Future<bool> deleteBookmarks() async {
Hive.deleteBoxFromDisk("bookmarks");
// Delete all items of a list in the shared preferences
Future<bool> deleteList(String listName) async {
Hive.deleteBoxFromDisk(listName);
if (kDebugMode) {
print("All bookmarks deleted");
print("All items of $listName deleted");
}
return true;
}
// Add a movie to the bookmarks list in the shared preferences
Future<bool> addBookmark({required FullShow fullShow}) async {
Box<HiveShowPreview> bookmarks = Hive.box<HiveShowPreview>('bookmarks');
HiveShowPreview hiveShow = await convertFullShowToHive(
fullShow, (bookmarks.length + 1).toString());
bookmarks.put(bookmarks.length + 1, hiveShow);
// Add an item to a list in the shared preferences
Future<bool> addShowToList(
{required FullShow fullShow, required String listName}) async {
Box<HiveShowPreview> list = Hive.box<HiveShowPreview>(listName);
HiveShowPreview hiveShow =
await convertFullShowToHive(fullShow, (list.length + 1).toString());
list.put(list.length + 1, hiveShow);
if (kDebugMode) {
print("Item added to bookmarks");
print("The item added to $listName");
}
return true;
}
// Delete a movie or tv show from the bookmarks list in the shared preferences
Future<bool> deleteBookmark({required String showId}) async {
Box<HiveShowPreview> bookmarks = Hive.box<HiveShowPreview>('bookmarks');
for (int i = 0; i < bookmarks.length; i++) {
if (bookmarks.getAt(i)?.id == showId) {
bookmarks.deleteAt(i);
// Delete an item from a list in the shared preferences
Future<bool> deleteFromList(
{required String showId, required String listName}) async {
Box<HiveShowPreview> list = Hive.box<HiveShowPreview>(listName);
for (int i = 0; i < list.length; i++) {
if (list.getAt(i)?.id == showId) {
list.deleteAt(i);
if (kDebugMode) {
print("Item deleted from bookmarks");
print("The item deleted from $listName");
}
return true;
}
@@ -41,20 +43,23 @@ class PreferencesShareholder {
return false;
}
// Get a bool value that is there any bookmarks in the shared preferences or not
Future<bool> isThereInBookmarks({required String showId}) async {
Box<HiveShowPreview> bookmarks = Hive.box<HiveShowPreview>('bookmarks');
for (int i = 0; i < bookmarks.length; i++) {
if (bookmarks.getAt(i)?.id == showId) {
if (kDebugMode) {
print("Item is in bookmarks");
// Get a map value that the item has been already added to which lists
Future<Map<String, bool>> isThereInLists({required String showId}) async {
List<String> listNames = ["collection", "watchlist", "history"];
Map<String, bool> result = {};
for (String listName in listNames) {
Box<HiveShowPreview> collection = Hive.box<HiveShowPreview>(listName);
for (int i = 0; i < collection.length; i++) {
if (collection.getAt(i)?.id == showId) {
if (kDebugMode) {
print("Item is in $listName");
}
result[listName] = true;
break;
}
return true;
}
result[listName] = false;
}
if (kDebugMode) {
print("Item is not in bookmarks");
}
return false;
return result;
}
}

View File

@@ -12,7 +12,7 @@ class HomeIMDbBox extends StatelessWidget {
width: 250,
height: 100,
decoration: BoxDecoration(
color: kSecondaryColor,
color: kImdbColor,
borderRadius: BorderRadius.circular(20),
),
child: Column(children: [

View File

@@ -28,7 +28,7 @@ class Top250TVsPage extends StatelessWidget {
color: kBackgroundColor,
size: 22.5,
)),
backgroundColor: kSecondaryColor,
backgroundColor: kImdbColor,
title: Text("IMDB Top 250 TVs",
style: GoogleFonts.poppins(
color: kBackgroundColor,

View File

@@ -28,7 +28,7 @@ class Top250MoviesPage extends StatelessWidget {
color: kBackgroundColor,
size: 22.5,
)),
backgroundColor: kSecondaryColor,
backgroundColor: kImdbColor,
title: Text("IMDB Top 250 Movies",
style: GoogleFonts.poppins(
color: kBackgroundColor,

View File

@@ -23,9 +23,9 @@ class MainController extends GetxController {
} catch (e) {}
}
if (index == 2) {
// Bookmarks page may sometimes doesn't have a scroll controller, so we need to check it
// collection page may sometimes doesn't have a scroll controller, so we need to check it
try {
bookmarksScrollController.animateTo(0,
collectionScrollController.animateTo(0,
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut);
// ignore: empty_catches
@@ -40,6 +40,6 @@ class MainController extends GetxController {
// Main pages scroll controller
ScrollController homeScrollController = ScrollController();
ScrollController searchScrollController = ScrollController();
ScrollController bookmarksScrollController = ScrollController();
ScrollController collectionScrollController = ScrollController();
ScrollController profileScrollController = ScrollController();
}

View File

@@ -5,9 +5,9 @@ import 'package:movielab/constants/colors.dart';
import 'package:movielab/pages/main/main_controller.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'home/home_page.dart';
import 'bookmarks/bookmarks_page.dart';
import 'search/search_page.dart';
import 'profile/profile.dart';
import 'watchlist/watchlist.dart';
class MainPage extends StatelessWidget {
const MainPage({Key? key}) : super(key: key);
@@ -58,7 +58,7 @@ class MainPage extends StatelessWidget {
),
GButton(
icon: Icons.bookmark_outline_rounded,
text: 'Bookmarks',
text: 'Watchlist',
),
GButton(
icon: Icons.podcasts_rounded,
@@ -81,6 +81,6 @@ class MainPage extends StatelessWidget {
const List<Widget> pages = <Widget>[
HomePage(),
SearchPage(),
BookmarksPage(),
WhatchlistPage(),
ProfilePage()
];

View File

@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
class BookmarksNavbar extends StatelessWidget {
const BookmarksNavbar({Key? key}) : super(key: key);
class WhatchlistNavbar extends StatelessWidget {
const WhatchlistNavbar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -12,7 +12,7 @@ class BookmarksNavbar extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Bookmarks",
Text("collection",
style: GoogleFonts.poppins(
color: Colors.white,
fontSize: 30,

View File

@@ -9,10 +9,10 @@ import 'package:movielab/modules/preferences_shareholder.dart';
import 'package:ms_undraw/ms_undraw.dart';
import '../../../models/hive/convertor.dart';
import '../../../widgets/loading_error.dart';
import '../../show/show_box/bookmarks_show_box.dart';
import '../../show/show_box/lists_show_box.dart';
class BookmarksPage extends StatelessWidget {
const BookmarksPage({Key? key}) : super(key: key);
class WhatchlistPage extends StatelessWidget {
const WhatchlistPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -27,7 +27,7 @@ class BookmarksPage extends StatelessWidget {
child: FittedBox(
child: FloatingActionButton(
onPressed: () {
preferencesShareholder.deleteBookmarks();
// preferencesShareholder.deletecollection();
},
tooltip: "Delete all",
backgroundColor: Colors.white,
@@ -41,25 +41,25 @@ class BookmarksPage extends StatelessWidget {
centerTitle: true,
automaticallyImplyLeading: false,
backgroundColor: kBackgroundColor,
title: Text("Bookmarks",
title: Text("collection",
style: GoogleFonts.poppins(
color: Colors.white,
fontSize: 25,
fontWeight: FontWeight.bold)),
),
body: ValueListenableBuilder<Box<HiveShowPreview>>(
valueListenable: Hive.box<HiveShowPreview>('bookmarks').listenable(),
valueListenable: Hive.box<HiveShowPreview>('collection').listenable(),
builder: (context, box, _) {
final bookmarks = box.values.toList().cast<HiveShowPreview>();
print(bookmarks.toString());
return bookmarks.isNotEmpty
final collection = box.values.toList().cast<HiveShowPreview>();
print(collection.toString());
return collection.isNotEmpty
? ListView.builder(
itemCount: bookmarks.length,
itemCount: collection.length,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) {
return BookmarksShowBox(
return ListShowBox(
showPreview: convertHiveToShowPreview(
bookmarks[bookmarks.length - index - 1]));
collection[collection.length - index - 1]));
},
)
: Column(

View File

@@ -88,7 +88,7 @@ class EpisodeShowBox extends StatelessWidget {
imDbRating,
softWrap: true,
style: GoogleFonts.ubuntu(
color: kSecondaryColor,
color: kImdbColor,
fontSize: 13.5,
fontWeight: FontWeight.w500),
),
@@ -99,7 +99,7 @@ class EpisodeShowBox extends StatelessWidget {
rating: double.parse(imDbRating) / 2,
itemBuilder: (context, index) => const Icon(
Icons.star,
color: kSecondaryColor,
color: kImdbColor,
),
unratedColor: kGreyColor,
itemCount: 5,

View File

@@ -102,7 +102,7 @@ class IMDBListShowBox extends StatelessWidget {
imDbRating,
softWrap: true,
style: GoogleFonts.ubuntu(
color: kSecondaryColor,
color: kImdbColor,
fontSize: 13.5,
fontWeight: FontWeight.w500),
),
@@ -113,7 +113,7 @@ class IMDBListShowBox extends StatelessWidget {
rating: double.parse(imDbRating) / 2,
itemBuilder: (context, index) => const Icon(
Icons.star,
color: kSecondaryColor,
color: kImdbColor,
),
unratedColor: kGreyColor,
itemCount: 5,

View File

@@ -8,10 +8,9 @@ import 'package:movielab/modules/preferences_shareholder.dart';
import 'package:movielab/pages/show/show_box/show_box_common.dart';
import '../../../models/show_models/show_preview_model.dart';
class BookmarksShowBox extends StatelessWidget {
class ListShowBox extends StatelessWidget {
final ShowPreview showPreview;
const BookmarksShowBox({Key? key, required this.showPreview})
: super(key: key);
const ListShowBox({Key? key, required this.showPreview}) : super(key: key);
@override
Widget build(BuildContext context) {
@@ -135,7 +134,7 @@ class BookmarksShowBox extends StatelessWidget {
imDbRating,
softWrap: true,
style: GoogleFonts.ubuntu(
color: kSecondaryColor,
color: kImdbColor,
fontSize: 13.5,
fontWeight: FontWeight.w500),
),
@@ -146,7 +145,7 @@ class BookmarksShowBox extends StatelessWidget {
rating: double.parse(imDbRating) / 2,
itemBuilder: (context, index) => const Icon(
Icons.star,
color: kSecondaryColor,
color: kImdbColor,
),
unratedColor: kGreyColor,
itemCount: 5,
@@ -169,5 +168,5 @@ class BookmarksShowBox extends StatelessWidget {
void delete(BuildContext context, ShowPreview showPreview) {
final preferencesShareholder = PreferencesShareholder();
preferencesShareholder.deleteBookmark(showId: showPreview.id);
// ToDo: preferencesShareholder.deleteBookmark(showId: showPreview.id);
}

View File

@@ -0,0 +1,151 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../../../../../constants/colors.dart';
class ShowPageBottonBar extends StatelessWidget {
const ShowPageBottonBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
height: 60,
child: Row(
children: [
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.alignLeft,
size: 22.5,
color: Colors.white,
),
),
onTap: () {
showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
)),
clipBehavior: Clip.antiAliasWithSaveLayer,
backgroundColor: kSecondaryColor,
builder: (context) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 20),
height: 235,
child: Column(
children: [
button(context,
icon: FontAwesomeIcons.circle,
text: 'Mark as watched'),
button(context,
icon: FontAwesomeIcons.bookmark,
text: 'Add to watchlist'),
button(context,
icon: FontAwesomeIcons.rectangleList,
text: 'Add to collection'),
],
),
);
},
);
},
),
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.arrowUpRightFromSquare,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.clapperboard,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.ellipsisVertical,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
],
),
);
}
Widget button(BuildContext context,
{required String text,
required IconData icon,
EdgeInsets margin = const EdgeInsets.symmetric(vertical: 7.5)}) {
return Container(
height: 50,
margin: margin,
width: MediaQuery.of(context).size.width - 100,
decoration: BoxDecoration(
color: const Color(0xff2a425f).withOpacity(0.75),
borderRadius: BorderRadius.circular(15)),
child: TextButton(
onPressed: () {},
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
),
child: Row(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: Icon(
icon,
color: Colors.white,
size: 20,
),
),
Text(
text,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w800),
),
],
)),
);
}
}

View File

@@ -20,9 +20,9 @@ class ShowPageMedia extends StatelessWidget {
GmButton(
text: "Posters",
onTap: () {
return null;
return;
},
color: kSecondaryColor,
color: kImdbColor,
icon: FontAwesomeIcons.blog),
const SizedBox(
width: 10,
@@ -30,7 +30,7 @@ class ShowPageMedia extends StatelessWidget {
GmButton(
text: "Images",
onTap: () {
return null;
return;
},
color: kPrimaryColor,
icon: FontAwesomeIcons.solidImages),
@@ -40,7 +40,7 @@ class ShowPageMedia extends StatelessWidget {
GmButton(
text: "Trailers",
onTap: () {
return null;
return;
},
color: kGreyColor,
icon: FontAwesomeIcons.compactDisc)

View File

@@ -46,18 +46,18 @@ class _ShowPageNavBarState extends State<ShowPageNavBar> {
onPressed: () {
isBookmarked
? {
preferencesShareholder.deleteBookmark(
showId: widget.show.id),
setState(() {
isBookmarked = false;
})
// preferencesShareholder.deleteBookmark(
// showId: widget.show.id),
// setState(() {
// isBookmarked = false;
// })
}
: {
preferencesShareholder.addBookmark(
fullShow: widget.show),
setState(() {
isBookmarked = true;
})
// preferencesShareholder.addBookmark(
// fullShow: widget.show),
// setState(() {
// isBookmarked = true;
// })
};
},
icon: Icon(

View File

@@ -24,7 +24,7 @@ class ShowPageRating extends StatelessWidget {
child: Text(imDbRating,
textAlign: TextAlign.center,
style: GoogleFonts.ubuntu(
color: kSecondaryColor,
color: kImdbColor,
fontSize: 18,
fontWeight: FontWeight.w700)),
),
@@ -32,7 +32,7 @@ class ShowPageRating extends StatelessWidget {
rating: double.parse(imDbRating) / 2,
itemBuilder: (context, index) => const Icon(
Icons.star,
color: kSecondaryColor,
color: kImdbColor,
),
unratedColor: kGreyColor,
itemCount: 5,

View File

@@ -0,0 +1,335 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:movielab/constants/colors.dart';
import 'package:movielab/models/show_models/full_show_model.dart';
import 'package:movielab/widgets/buttons/glassmorphism_button.dart';
// ignore: must_be_immutable
class ShowPageAddWatchTime extends StatefulWidget {
final FullShow show;
const ShowPageAddWatchTime({Key? key, required this.show}) : super(key: key);
@override
State<ShowPageAddWatchTime> createState() => _ShowPageAddWatchTimeState();
}
class _ShowPageAddWatchTimeState extends State<ShowPageAddWatchTime> {
bool isOtherDateSectionOpen = false;
bool showDateSelector = false;
DateTime selectedDate = DateTime.now();
TimeOfDay selectedTime = TimeOfDay.now();
List<String> months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];
Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker(
context: context,
builder: (BuildContext context, child) {
return Theme(
data: Theme.of(context).copyWith(
dialogBackgroundColor: kSecondaryColor,
primaryColor: kPrimaryColor,
colorScheme: const ColorScheme.light(
primary: kPrimaryColor,
onPrimary: Colors.white,
onSurface: Colors.white,
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
primary: kPrimaryColor,
),
),
),
child: child!);
},
initialDate: selectedDate,
currentDate: DateTime.now(),
selectableDayPredicate: (DateTime date) =>
date.isAfter(DateTime.now()) ? false : true,
firstDate: DateTime(1901),
lastDate: DateTime(2101));
if (picked != null && picked != selectedDate) {
setState(() {
selectedDate = picked;
print(selectedDate);
});
}
}
Future<void> _selectTime(BuildContext context) async {
final TimeOfDay? timeOfDay = await showTimePicker(
context: context,
builder: (BuildContext context, child) {
return Theme(
data: ThemeData.dark().copyWith(
primaryColor: kPrimaryColor,
timePickerTheme: const TimePickerThemeData(
backgroundColor: kSecondaryColor,
dialTextColor: Colors.white,
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
primary: Colors.white,
),
),
),
child: child!);
},
initialTime: selectedTime,
initialEntryMode: TimePickerEntryMode.dial,
);
if (timeOfDay != null && timeOfDay != selectedTime) {
setState(() {
selectedTime = timeOfDay;
});
}
}
@override
Widget build(BuildContext context) {
return AnimatedContainer(
duration: const Duration(milliseconds: 125),
height: !isOtherDateSectionOpen ? 225 : 350,
child: Column(
children: [
Row(
children: [
Padding(
padding: const EdgeInsets.only(
left: 25, right: 25, top: 25, bottom: 15),
child: Text(
"When did you watch this?",
style: TextStyle(
color: Colors.white.withOpacity(0.25),
fontSize: 13.5,
fontWeight: FontWeight.bold),
),
),
],
),
TextButton(
onPressed: () {},
style: TextButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 25, vertical: 10)),
child: Row(
children: const [
Icon(
FontAwesomeIcons.calendar,
color: Colors.white,
),
SizedBox(
width: 15,
),
Text(
"Right now",
style: TextStyle(
color: Colors.white,
fontSize: 13.5,
fontWeight: FontWeight.w700),
)
],
),
),
TextButton(
onPressed: () {},
style: TextButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 25, vertical: 10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: const [
Icon(
FontAwesomeIcons.film,
color: Colors.white,
),
SizedBox(
width: 15,
),
Text(
"Release date",
style: TextStyle(
color: Colors.white,
fontSize: 13.5,
fontWeight: FontWeight.w700),
)
],
),
Text(
widget.show.releaseDate,
style: TextStyle(
color: Colors.white.withOpacity(0.5),
fontSize: 10,
fontWeight: FontWeight.w700),
)
],
),
),
TextButton(
onPressed: () async {
if (!isOtherDateSectionOpen) {
setState(() {
isOtherDateSectionOpen = true;
});
await Future.delayed(const Duration(milliseconds: 100));
setState(() {
showDateSelector = true;
});
} else {
setState(() {
isOtherDateSectionOpen = false;
showDateSelector = false;
});
}
},
style: TextButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 25, vertical: 10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(
FontAwesomeIcons.penToSquare,
color:
!isOtherDateSectionOpen ? Colors.white : kAccentColor,
),
const SizedBox(
width: 15,
),
Text(
"Other date",
style: TextStyle(
color: !isOtherDateSectionOpen
? Colors.white
: kAccentColor,
fontSize: 13.5,
fontWeight: FontWeight.w700),
)
],
),
Icon(
!isOtherDateSectionOpen
? FontAwesomeIcons.angleDown
: FontAwesomeIcons.angleUp,
color:
!isOtherDateSectionOpen ? Colors.white : kAccentColor,
size: 17.5)
],
),
),
const SizedBox(
height: 7.5,
),
showDateSelector
? Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () => _selectDate(context),
style: TextButton.styleFrom(padding: EdgeInsets.zero),
child: IntrinsicWidth(
child: TextField(
readOnly: true,
onTap: () => _selectDate(context),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white.withOpacity(0.5),
width: 2),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white.withOpacity(0.5),
width: 2),
),
labelText: "Date",
hintText:
"${months[selectedDate.month - 1]} ${selectedDate.day}, ${selectedDate.year}",
floatingLabelBehavior:
FloatingLabelBehavior.always,
labelStyle: GoogleFonts.ubuntu(
color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.w700),
hintStyle: GoogleFonts.ubuntu(
color: Colors.white,
fontWeight: FontWeight.w600)),
),
),
),
const SizedBox(
width: 15,
),
TextButton(
onPressed: () => _selectTime(context),
style: TextButton.styleFrom(padding: EdgeInsets.zero),
child: IntrinsicWidth(
child: TextField(
readOnly: true,
onTap: () => _selectTime(context),
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white.withOpacity(0.5),
width: 2),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white.withOpacity(0.5),
width: 2),
),
labelText: "Date",
hintText:
"${selectedTime.hour} : ${selectedTime.minute}",
floatingLabelBehavior:
FloatingLabelBehavior.always,
labelStyle: GoogleFonts.ubuntu(
color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.w700),
hintStyle: GoogleFonts.ubuntu(
color: Colors.white,
fontWeight: FontWeight.w600)),
),
),
),
],
),
const SizedBox(
height: 17.5,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GmButton(
text: "Apply",
onTap: () {},
backgroundColor: kAccentColor.withOpacity(0.75),
color: Colors.white)
],
)
],
)
: const SizedBox.shrink(),
],
),
);
}
}

View File

@@ -2,7 +2,6 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:movielab/constants/types.dart';
import 'package:movielab/modules/system_ui_overlay_style.dart';
import 'package:movielab/pages/show/show_page/sections/media.dart';
@@ -11,7 +10,9 @@ import 'package:movielab/widgets/loading_error.dart';
import '../../../constants/colors.dart';
import '../../../modules/preferences_shareholder.dart';
import 'get_show_info.dart';
import 'sections/bottom_bar/bottom_bar.dart';
import 'sections/index.dart';
import 'sections/watchtime.dart';
// ignore: must_be_immutable
class ShowPage extends StatefulWidget {
@@ -22,10 +23,10 @@ class ShowPage extends StatefulWidget {
State<ShowPage> createState() => _ShowPageState();
}
class _ShowPageState extends State<ShowPage> {
class _ShowPageState extends State<ShowPage> with TickerProviderStateMixin {
RequestResult _loadingStatus = RequestResult.LOADING;
dynamic show;
bool isBookmarked = false;
Map<String, bool> _isThereInLists = {};
ScrollController _scrollController = ScrollController();
bool _isBottomAppBarVisible = true;
final preferencesShareholder = PreferencesShareholder();
@@ -89,93 +90,38 @@ class _ShowPageState extends State<ShowPage> {
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
height: _isBottomAppBarVisible ? 60 : 0.0,
child: BottomAppBar(
shape: const CircularNotchedRectangle(),
clipBehavior: Clip.antiAlias,
notchMargin: 7.5,
color: const Color(0xff132d4e),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
height: 60,
child: Row(
children: [
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.alignLeft,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.arrowUpRightFromSquare,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.clapperboard,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
const SizedBox(
width: 7.5,
),
InkWell(
borderRadius: BorderRadius.circular(30),
child: const SizedBox(
height: 45,
width: 45,
child: Icon(
FontAwesomeIcons.ellipsisVertical,
size: 22.5,
color: Colors.white,
),
),
onTap: () {},
),
],
),
),
],
),
),
child: const BottomAppBar(
shape: CircularNotchedRectangle(),
clipBehavior: Clip.antiAlias,
notchMargin: 7.5,
color: kSecondaryColor,
child: ShowPageBottonBar()),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
onPressed: () {
_isThereInLists["history"] != true
? showModalBottomSheet(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
)),
clipBehavior: Clip.antiAliasWithSaveLayer,
backgroundColor: kSecondaryColor,
transitionAnimationController: AnimationController(
duration: const Duration(milliseconds: 225),
vsync: this),
builder: (context) {
return ShowPageAddWatchTime(
show: show,
);
})
: null;
},
backgroundColor: kPrimaryColor,
child: const Icon(Icons.add),
child: _isThereInLists["history"] != true
? const Icon(Icons.add)
: const Icon(Icons.check),
),
floatingActionButtonLocation: _isBottomAppBarVisible
? FloatingActionButtonLocation.endDocked
@@ -241,10 +187,10 @@ class _ShowPageState extends State<ShowPage> {
],
),
),
ShowPageNavBar(
show: show,
isBookmarked: isBookmarked,
)
// ShowPageNavBar(
// show: show,
// isBookmarked: isBookmarked,
// )
],
),
),
@@ -303,10 +249,12 @@ class _ShowPageState extends State<ShowPage> {
_loadingStatus = RequestResult.SUCCESS;
});
preferencesShareholder
.isThereInBookmarks(showId: show.id)
.then((value) {
isBookmarked = value;
});
.isThereInLists(showId: widget.id)
.then((value) => {
setState(() {
_isThereInLists = value;
})
});
} else {
setState(() {
_loadingStatus = RequestResult.FAILURE;

View File

@@ -1,6 +1,6 @@
import 'package:get/get.dart';
import 'package:movielab/constants/types.dart';
import 'package:movielab/pages/main/bookmarks/bookmarks_controller.dart';
import 'package:movielab/pages/main/collection/collection_controller.dart';
import 'package:movielab/pages/main/home/home_data_controller.dart';
import 'package:movielab/pages/splash/get_Initial_data.dart';
import 'package:test/test.dart';
@@ -8,7 +8,7 @@ import 'package:test/test.dart';
void main() {
test('getInitialData', () async {
Get.put(HomeDataController());
Get.put(BookmarksPageController());
Get.put(collectionPageController());
var result = await getInitialData();
expect(result, isNotNull);