Skip to content

Commit d168b92

Browse files
committed
Cleaned up state
1 parent 19ae2b7 commit d168b92

24 files changed

+397
-1919
lines changed

dataconnect/dataconnect/connector/mutations.gql

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@ mutation AddFavoritedMovie($movieId: UUID!) @auth(level: USER) {
1313
favorite_movie_upsert(data: { userId_expr: "auth.uid", movieId: $movieId })
1414
}
1515

16-
1716
# Remove a movie from the user's favorites list
1817
mutation DeleteFavoritedMovie($movieId: UUID!) @auth(level: USER) {
1918
favorite_movie_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
2019
}
2120

22-
# Add a movie to the user's favorites list
23-
mutation DeleteFavoritedActor($actorId: UUID!) @auth(level: USER) {
24-
favorite_actor_delete(key: { userId_expr: "auth.uid", actorId: $actorId })
25-
}
26-
mutation DeleteWatchedMovie($movieId: UUID!) @auth(level: USER) {
27-
watched_movie_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
28-
}
29-
3021
# Add a review for a movie
3122
mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!)
3223
@auth(level: USER) {

dataconnect/dataconnect/connector/queries.gql

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -140,39 +140,13 @@ query GetCurrentUser @auth(level: USER) {
140140
}
141141
}
142142
}
143-
favoriteActors: favorite_actors_on_user {
144-
actor {
145-
id
146-
name
147-
imageUrl
148-
}
149-
}
150-
watchedMovies: watched_movies_on_user {
151-
movie {
152-
id
153-
title
154-
genre
155-
imageUrl
156-
releaseYear
157-
rating
158-
description
159-
tags
160-
metadata: movieMetadatas_on_movie {
161-
director
162-
}
163-
}
164-
}
165-
166143
}
167144
}
168145

169146
query GetMovieInfoForUser($movieId: UUID!) @auth(level: USER) {
170147
favorite_movie(key: { userId_expr: "auth.uid", movieId: $movieId }) {
171148
movieId
172149
}
173-
watched_movie(key: { userId_expr: "auth.uid", movieId: $movieId }) {
174-
movieId
175-
}
176150
}
177151

178152

dataconnect/dataconnect/schema/schema.gql

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,3 @@ type FavoriteMovie
9494
user: User!
9595
movie: Movie!
9696
}
97-
type FavoriteActor
98-
@table(name: "FavoriteActors", singular: "favorite_actor", plural: "favorite_actors", key: ["user", "actor"]) {
99-
# @ref is implicit
100-
user: User!
101-
actor: Actor!
102-
}
103-
type WatchedMovie
104-
@table(name: "WatchedMovies", singular: "watched_movie", plural: "watched_movies", key: ["user", "movie"]) {
105-
# @ref is implicit
106-
user: User!
107-
movie: Movie!
108-
}

dataconnect/firebase.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
11
{
2+
"flutter": {
3+
"platforms": {
4+
"android": {
5+
"default": {
6+
"projectId": "quickstart-flutter-cc624",
7+
"appId": "1:731568610039:android:2fda8b27330be9447251f2",
8+
"fileOutput": "android/app/google-services.json"
9+
}
10+
},
11+
"ios": {
12+
"default": {
13+
"projectId": "quickstart-flutter-cc624",
14+
"appId": "1:731568610039:ios:e78b43f1d75a77d87251f2",
15+
"uploadDebugSymbols": false,
16+
"fileOutput": "ios/Runner/GoogleService-Info.plist"
17+
}
18+
},
19+
"dart": {
20+
"lib/firebase_options.dart": {
21+
"projectId": "quickstart-flutter-cc624",
22+
"configurations": {
23+
"android": "1:731568610039:android:2fda8b27330be9447251f2",
24+
"ios": "1:731568610039:ios:e78b43f1d75a77d87251f2",
25+
"macos": "1:731568610039:ios:e78b43f1d75a77d87251f2",
26+
"web": "1:731568610039:web:2896847d0f5655fb7251f2",
27+
"windows": "1:731568610039:web:3c1e404f955f0b467251f2"
28+
}
29+
}
30+
},
31+
"macos": {
32+
"default": {
33+
"projectId": "quickstart-flutter-cc624",
34+
"appId": "1:731568610039:ios:e78b43f1d75a77d87251f2",
35+
"uploadDebugSymbols": false,
36+
"fileOutput": "macos/Runner/GoogleService-Info.plist"
37+
}
38+
}
39+
}
40+
},
241
"dataconnect": { "source": "dataconnect" },
342
"emulators": { "dataconnect": { "port": 9399 }, "auth": { "port": 9400 } }
443
}

dataconnect/lib/actor_detail.dart

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import 'package:dataconnect/movie_state.dart';
12
import 'package:dataconnect/movies_connector/movies.dart';
3+
import 'package:dataconnect/widgets/list_movies.dart';
24
import 'package:flutter/material.dart';
35

46
class ActorDetail extends StatefulWidget {
@@ -16,10 +18,8 @@ class _ActorDetailState extends State<ActorDetail> {
1618
@override
1719
void initState() {
1820
super.initState();
19-
MoviesConnector.instance
20-
.getActorById(id: widget.actorId)
21-
.execute()
22-
.then((value) {
21+
22+
MovieState.getActorById(widget.actorId).then((value) {
2323
setState(() {
2424
loading = false;
2525
actor = value.data.actor;
@@ -50,28 +50,23 @@ class _ActorDetailState extends State<ActorDetail> {
5050
),
5151
),
5252
),
53-
Expanded(
54-
child: Padding(
55-
padding: const EdgeInsets.fromLTRB(15, 0, 0, 0),
56-
// child: Column(children: [Text(actor!.info!)]),
57-
))
5853
]),
59-
Row(
60-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
61-
children: [
62-
// TODO(mtewani): Check if the movie has been watched by the user
63-
OutlinedButton.icon(
64-
onPressed: () {
65-
// TODO(mtewani): Check if user is logged in.
66-
},
67-
icon: const Icon(Icons.favorite),
68-
label: const Text('Add To Favorites'),
69-
)
70-
],
71-
)
7254
];
7355
}
7456

57+
Widget _buildMainRoles() {
58+
return ListMovies(
59+
movies: MovieState.convertMainActorDetail(actor!.mainActors),
60+
title: "Main Roles");
61+
}
62+
63+
Widget _buildSupportingRoles() {
64+
return ListMovies(
65+
movies:
66+
MovieState.convertSupportingActorDetail(actor!.supportingActors),
67+
title: "Supporting Roles");
68+
}
69+
7570
@override
7671
Widget build(BuildContext context) {
7772
return Scaffold(
@@ -86,7 +81,11 @@ class _ActorDetailState extends State<ActorDetail> {
8681
padding: const EdgeInsets.all(30),
8782
child: SingleChildScrollView(
8883
child: Column(
89-
children: [..._buildActorInfo()],
84+
children: [
85+
..._buildActorInfo(),
86+
_buildMainRoles(),
87+
_buildSupportingRoles()
88+
],
9089
)))),
9190
);
9291
}

dataconnect/lib/destination.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ class Route {
1414
}
1515

1616
var homePath = Route(path: '/home', label: 'Home', iconData: Icons.home);
17-
var genrePath = Route(path: '/genres', label: 'Genres', iconData: Icons.list);
1817
var searchPath =
1918
Route(path: '/search', label: 'Search', iconData: Icons.search);
2019
var profilePath =
2120
Route(path: '/profile', label: 'Profile', iconData: Icons.person);
22-
var paths = [homePath, genrePath, searchPath, profilePath];
21+
var paths = [homePath, searchPath, profilePath];

dataconnect/lib/extensions.dart

Lines changed: 0 additions & 49 deletions
This file was deleted.

dataconnect/lib/genre_list_movies.dart

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)