Skip to content

Commit

Permalink
Merge pull request #40 from arafaysaleem/release
Browse files Browse the repository at this point in the history
Release 10/06/2021
  • Loading branch information
arafaysaleem authored Jun 10, 2021
2 parents 0fb6176 + b6509c1 commit ba5f591
Show file tree
Hide file tree
Showing 22 changed files with 269 additions and 175 deletions.
1 change: 1 addition & 0 deletions lib/enums/movie_type_enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ enum MovieType {
@JsonValue("now_showing") NOW_SHOWING,
@JsonValue("coming_soon") COMING_SOON,
@JsonValue("removed") REMOVED,
ALL_MOVIES,
}

/// A utility with extensions for enum name and serialized value.
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/utils/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Constants {
/// It is measured from the bottom of the screen, that is
/// behind the android system navigation.
/// Used to prevent overlapping of android navigation with the button.
static const double bottomInsetsLow = 45;
static const double bottomInsetsLow = 48;

/// The max number of rows a theater can contain
static const int maxSeatRows = 12;
Expand Down
3 changes: 1 addition & 2 deletions lib/models/movie_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MovieModel with _$MovieModel {
required String summary,
required String trailerUrl,
required String posterUrl,
required double? rating,
@Default(0.0) double rating,
@JsonKey(toJson: toJsonGenres) required List<GenreModel> genres,
required MovieType movieType,
}) = _MovieModel;
Expand All @@ -37,7 +37,6 @@ class MovieModel with _$MovieModel {
summary: "",
trailerUrl: "",
posterUrl: "",
rating: null,
genres: [],
movieType: MovieType.COMING_SOON,
);
Expand Down
33 changes: 17 additions & 16 deletions lib/providers/movies_provider.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import 'package:hooks_riverpod/hooks_riverpod.dart';

//Providers
import 'all_providers.dart';

//Services
import '../services/repositories/movies_repository.dart';

//Enums
import '../enums/movie_type_enum.dart';

Expand All @@ -14,17 +8,24 @@ import '../models/genre_model.dart';
import '../models/movie_model.dart';
import '../models/movie_role_model.dart';

final moviesFuture = FutureProvider.family.autoDispose<List<MovieModel>, MovieType?>(
(ref, movieType) async {
final _moviesProvider = ref.watch(moviesProvider);
//Services
import '../services/repositories/movies_repository.dart';

//Providers
import 'all_providers.dart';

final moviesList = await _moviesProvider.getAllMovies(
movieType: movieType,
);
final moviesFuture = FutureProvider.autoDispose<List<MovieModel>>((ref) async {
final _moviesProvider = ref.watch(moviesProvider);
final _movieType = ref.watch(selectedMovieTypeProvider).state;

return await _moviesProvider.getAllMovies(
movieType: _movieType == MovieType.ALL_MOVIES ? null : _movieType,
);
});

return moviesList;
},
);
final selectedMovieTypeProvider = StateProvider<MovieType>((ref) {
return MovieType.ALL_MOVIES;
});

final selectedMovieProvider = StateProvider<MovieModel>((ref) {
return MovieModel.initial();
Expand Down Expand Up @@ -125,7 +126,7 @@ class MoviesProvider {
return await _moviesRepository.delete(movieId: movieId);
}

void cancelNetworkRequest(){
void cancelNetworkRequest() {
_moviesRepository.cancelRequests();
}
}
1 change: 1 addition & 0 deletions lib/views/screens/app_startup_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class AppStartupScreen extends HookWidget {
const AppStartupScreen();

Widget build(BuildContext context) {
print(MediaQuery.of(context).padding.bottom);
final authState = useProvider(authProvider);
return authState.maybeWhen(
authenticated: (fullName) => const WelcomeScreen(),
Expand Down
4 changes: 2 additions & 2 deletions lib/views/screens/movies_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MoviesScreen extends HookWidget {
@override
Widget build(BuildContext context) {
final screenHeight = context.screenHeight;
final movies = useProvider(moviesFuture(null));
final movies = useProvider(moviesFuture);
return Scaffold(
resizeToAvoidBottomInset: false,
body: AnimatedSwitcher(
Expand Down Expand Up @@ -102,7 +102,7 @@ class MoviesScreen extends HookWidget {
return CustomErrorWidget.dark(
error: error,
retryCallback: () {
context.refresh(moviesFuture(null));
context.refresh(moviesFuture);
},
height: screenHeight * 0.5,
);
Expand Down
3 changes: 2 additions & 1 deletion lib/views/screens/shows_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ShowsScreen extends HookWidget {
context.router.pop();
},
),

const SizedBox(width: 20),

//Movie Title
Expand All @@ -71,7 +72,7 @@ class ShowsScreen extends HookWidget {
),
),

const SizedBox(width: 20),
const SizedBox(width: 50),
],
),

Expand Down
2 changes: 1 addition & 1 deletion lib/views/screens/theater_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class TheaterScreen extends HookWidget {
borderWidth: 1.5,
fontWeight: FontWeight.bold,
backgroundColor: Colors.red.shade700.withOpacity(0.3),
physics: const BouncingScrollPhysics(),
isScrollable: true,
);
},
),
Expand Down
16 changes: 8 additions & 8 deletions lib/views/skeletons/movies_skeleton_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class MoviesSkeletonLoader extends StatelessWidget {
//Left container
ShimmerLoader(
child: Container(
height: 0.62 * screenHeight,
height: 0.63 * screenHeight,
width: 40,
decoration: const BoxDecoration(
color: Constants.lightSkeletonColor,
borderRadius: BorderRadius.only(
topRight: Radius.circular(30),
),
),
padding: const EdgeInsets.fromLTRB(0, 20, 20, 200),
padding: const EdgeInsets.fromLTRB(0, 20, 20, 260),
child: const DecoratedBox(
decoration: BoxDecoration(
color: Constants.darkSkeletonColor,
Expand All @@ -61,8 +61,8 @@ class MoviesSkeletonLoader extends StatelessWidget {
//Center container
ShimmerLoader(
child: Container(
height: 0.68 * screenHeight,
width: 235,
height: 0.675 * screenHeight,
width: 240,
decoration: const BoxDecoration(
color: Constants.lightSkeletonColor,
borderRadius: BorderRadius.only(
Expand All @@ -76,7 +76,7 @@ class MoviesSkeletonLoader extends StatelessWidget {
//Image Box
SizedBox(
width: double.infinity,
height: 255,
height: 265,
child: DecoratedBox(
decoration: BoxDecoration(
color: Constants.darkSkeletonColor,
Expand All @@ -89,7 +89,7 @@ class MoviesSkeletonLoader extends StatelessWidget {

//Title Box
SizedBox(
height: 45,
height: 40,
width: 160,
child: DecoratedBox(
decoration: BoxDecoration(
Expand Down Expand Up @@ -150,15 +150,15 @@ class MoviesSkeletonLoader extends StatelessWidget {
//Right Container
ShimmerLoader(
child: Container(
height: 0.62 * screenHeight,
height: 0.63 * screenHeight,
width: 40,
decoration: const BoxDecoration(
color: Constants.lightSkeletonColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
),
),
padding: const EdgeInsets.fromLTRB(20, 20, 0, 200),
padding: const EdgeInsets.fromLTRB(20, 20, 0, 260),
child: const DecoratedBox(
decoration: BoxDecoration(
color: Constants.darkSkeletonColor,
Expand Down
64 changes: 39 additions & 25 deletions lib/views/widgets/common/custom_chips_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class CustomChipsList extends StatelessWidget {
final double chipHeight, chipGap;
final double? chipWidth;
final double fontSize;
final bool isScrollable;
final FontWeight? fontWeight;
final double borderWidth;
final ScrollPhysics physics;
final Color borderColor, backgroundColor, contentColor;

const CustomChipsList({
Expand All @@ -19,7 +19,7 @@ class CustomChipsList extends StatelessWidget {
this.chipGap = 0.0,
this.fontSize = 12,
this.borderWidth = 1.0,
this.physics = const NeverScrollableScrollPhysics(),
this.isScrollable = false,
this.borderColor = Constants.textGreyColor,
this.backgroundColor = Colors.white,
this.contentColor = Constants.textGreyColor,
Expand All @@ -31,30 +31,44 @@ class CustomChipsList extends StatelessWidget {
Widget build(BuildContext context) {
return SizedBox(
height: chipHeight,
child: ListView.separated(
physics: physics,
scrollDirection: Axis.horizontal,
itemCount: chipContents.length,
separatorBuilder: (ctx, i) => SizedBox(width: chipGap),
itemBuilder: (ctx, i) => Container(
width: chipWidth,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: const BorderRadius.all(Radius.circular(20)),
border: Border.all(color: borderColor, width: borderWidth),
),
child: Center(
child: Text(
chipContents[i],
style: TextStyle(
color: contentColor,
fontSize: fontSize,
height: 1,
fontWeight: fontWeight
),
child: isScrollable
? ListView.separated(
physics: const BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: chipContents.length,
separatorBuilder: (ctx, i) => SizedBox(width: chipGap),
itemBuilder: (ctx, i) => buildChipListItem(i),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (var i = 0; i < chipContents.length; i++)
Padding(
padding: EdgeInsets.only(left: i == 0 ? 0 : chipGap),
child: buildChipListItem(i),
)
],
),
),
);
}

Container buildChipListItem(int i) {
return Container(
width: chipWidth,
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 3),
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: const BorderRadius.all(Radius.circular(20)),
border: Border.all(color: borderColor, width: borderWidth),
),
child: Center(
child: Text(
chipContents[i],
style: TextStyle(
color: contentColor,
fontSize: fontSize,
height: 1,
fontWeight: fontWeight),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/views/widgets/common/ratings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Ratings extends StatelessWidget {
children: [
//Rating number
Text(
rating.toString(),
rating == 0 ? "N/A" : rating.toString(),
style: context.bodyText2.copyWith(
color: Colors.black,
fontWeight: FontWeight.bold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _FloatingMoviePostersState extends State<FloatingMoviePosters> {
right: 0,
height: 300,
child: ColoredBox(
color: Colors.black54,
color: Colors.black45,
),
),

Expand Down
12 changes: 6 additions & 6 deletions lib/views/widgets/movie_details/movie_actors_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';

//Enums
import '../../../enums/role_type_enum.dart';
import '../../../helper/extensions/context_extensions.dart';

//Helpers
import '../../../helper/utils/constants.dart';
import '../../../helper/extensions/context_extensions.dart';

//Models
import '../../../models/movie_role_model.dart';
Expand All @@ -22,12 +22,12 @@ import '../../../services/networking/network_exception.dart';
//Placeholders
import '../../skeletons/actor_picture_placeholder.dart';

//Widgets
import '../common/custom_network_image.dart';

//Skeletons
import '../../skeletons/movie_actors_skeleton_loader.dart';

//Widgets
import '../common/custom_network_image.dart';

final movieRolesFuture = FutureProvider.family<List<MovieRoleModel>, int>(
(ref, movieId) async {
final _moviesProvider = ref.watch(moviesProvider);
Expand All @@ -43,7 +43,7 @@ final movieRolesFuture = FutureProvider.family<List<MovieRoleModel>, int>(
class MovieActorsList extends HookWidget {
const MovieActorsList();

EdgeInsets getImagePadding({required bool isFirst,required bool isLast}) {
EdgeInsets getImagePadding({required bool isFirst, required bool isLast}) {
if (isFirst) {
return const EdgeInsets.only(left: 20);
} else if (isLast) {
Expand Down Expand Up @@ -83,7 +83,7 @@ class MovieActorsList extends HookWidget {
switchOutCurve: Curves.easeInBack,
child: movieRoles.when(
data: (movieRoles) => SizedBox(
height: 140,
height: context.screenHeight / 5.38,
child: ListView.separated(
scrollDirection: Axis.horizontal,
physics: const BouncingScrollPhysics(),
Expand Down
13 changes: 5 additions & 8 deletions lib/views/widgets/movie_details/movie_details_column.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ class MovieDetailsColumn extends HookWidget {
const SizedBox(height: 15),

//Genres
SizedBox(
width: 210,
child: CustomChipsList(
chipHeight: 26,
chipGap: 9,
chipContents: movie.genreNames.sublist(0, 3),
),
CustomChipsList(
chipHeight: 26,
chipGap: 9,
chipContents: movie.genreNames.sublist(0, 3),
),

const SizedBox(height: 15),

//Ratings
if (movie.rating != null) Ratings(rating: movie.rating!),
Ratings(rating: movie.rating),

const SizedBox(height: 15),

Expand Down
6 changes: 3 additions & 3 deletions lib/views/widgets/movie_details/movie_details_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class _MovieDetailsSheetState extends State<MovieDetailsSheet> {
// change poster size between these two extents
var endExtent = 0.0;
final extentRange = startExtent - endExtent;
// scaleRatio goes from 1.0 -> 1.2
final scaleRange = 1 - 1.2;
// scaleRatio goes from 1.0 -> 2.2
final scaleRange = 1 - 2.2;
final extentRatio = (slide - endExtent) / extentRange;
return extentRatio * scaleRange + 1.2;
return extentRatio * scaleRange + 2.2;
}

void _onPanelSlide(double slide, AnimationController animationController) {
Expand Down
Loading

0 comments on commit ba5f591

Please sign in to comment.