Skip to content

Commit 2ec2e2f

Browse files
committed
Added detail and signin pages
1 parent c20034c commit 2ec2e2f

File tree

25 files changed

+1510
-99
lines changed

25 files changed

+1510
-99
lines changed

dataconnect/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<application
33
android:label="dataconnect"
44
android:name="${applicationName}"
5+
android:networkSecurityConfig="@xml/network_security_config"
56
android:icon="@mipmap/ic_launcher">
67
<activity
78
android:name=".MainActivity"

dataconnect/dataconnect/.dataconnect/schema/main/input.gql

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,62 @@ input FavoriteMovie_Order {
293293
user: User_Order
294294
}
295295
"""
296+
✨ Generated filter input type for table 'Genre'. This input allows filtering objects using various conditions. Use `_or`, `_and`, and `_not` to compose complex filters.
297+
"""
298+
input Genre_Filter {
299+
"""
300+
Apply multiple filter conditions using `AND` logic.
301+
"""
302+
_and: [Genre_Filter!]
303+
"""
304+
Negate the result of the provided filter condition.
305+
"""
306+
_not: Genre_Filter
307+
"""
308+
Apply multiple filter conditions using `OR` logic.
309+
"""
310+
_or: [Genre_Filter!]
311+
"""
312+
✨ Generated from Field `Genre`.`genre` of type `String`
313+
"""
314+
genre: String_Filter
315+
}
316+
"""
317+
✨ Generated first-row input type for table 'Genre'. This input selects the first row matching the filter criteria, ordered according to the specified conditions.
318+
"""
319+
input Genre_FirstRow {
320+
"""
321+
Order the result by the specified fields.
322+
"""
323+
orderBy: [Genre_Order!]
324+
"""
325+
Filters rows based on the specified conditions.
326+
"""
327+
where: Genre_Filter
328+
}
329+
"""
330+
✨ Generated list filter input type for table 'Genre'. This input applies filtering logic based on the count or existence of related objects that matches certain criteria.
331+
"""
332+
input Genre_ListFilter {
333+
"""
334+
The desired number of objects that match the condition (defaults to at least one).
335+
"""
336+
count: Int_Filter = {gt:0}
337+
"""
338+
Condition of the related objects to filter for.
339+
"""
340+
exist: Genre_Filter
341+
}
342+
"""
343+
✨ Generated order input type for table 'Genre'. This input defines the sorting order of rows in query results based on one or more fields.
344+
"""
345+
input Genre_Order {
346+
"""
347+
✨ Generated from Field `Genre`.`genre` of type `String`
348+
"""
349+
genre: OrderDirection
350+
}
351+
"""
296352
✨ Generated data input type for table 'Movie'. It includes all necessary fields for creating or upserting rows into table.
297353
"""
298354
input Movie_Data {

dataconnect/dataconnect/.dataconnect/schema/main/query.gql

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,30 @@ extend type Query {
171171
limit: Int = 100
172172
): [FavoriteMovie!]! @fdc_generated(from: "FavoriteMovie", purpose: QUERY_MULTIPLE)
173173
"""
174+
✨ List `Genre` objects in the table, optionally filtered by `where` conditions.
175+
"""
176+
genres(
177+
"""
178+
Filter condition to narrow down the query results.
179+
"""
180+
where: Genre_Filter
181+
182+
"""
183+
Order the query results by specific fields.
184+
"""
185+
orderBy: [Genre_Order!]
186+
187+
"""
188+
Number of rows to skip before starting to return the results.
189+
"""
190+
offset: Int
191+
192+
"""
193+
Maximum number of rows to return (defaults to 100 rows).
194+
"""
195+
limit: Int = 100
196+
): [Genre!]! @fdc_generated(from: "Genre", purpose: QUERY_MULTIPLE)
197+
"""
174198
✨ List `Movie` objects in the table, optionally filtered by `where` conditions.
175199
"""
176200
movies(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
connectorId: movies
22
generate:
33
dartSdk:
4-
outputDir: ../lib/movies_connector
4+
outputDir: ../../lib/movies_connector
55
package: movies_connector

dataconnect/dataconnect/connector/queries.gql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@ query ListMovies($orderByRating: OrderDirection, $orderByReleaseYear: OrderDirec
1717
description
1818
}
1919
}
20+
query ListMoviesByGenre($genre: String!, $orderByRating: OrderDirection, $orderByReleaseYear: OrderDirection, $limit: Int) @auth(level: PUBLIC) {
21+
movies(where: {
22+
genre: {
23+
eq: $genre
24+
}
25+
}, orderBy: [
26+
{ rating: $orderByRating },
27+
{ releaseYear: $orderByReleaseYear }
28+
]
29+
limit: $limit) {
30+
id
31+
title
32+
imageUrl
33+
releaseYear
34+
genre
35+
rating
36+
tags
37+
description
38+
}
39+
}
40+
41+
query ListGenres @auth(level: PUBLIC) {
42+
genres {
43+
genre
44+
}
45+
}
2046

2147
# Get movie by id
2248
query GetMovieById($id: UUID!) @auth(level: PUBLIC) {

dataconnect/dataconnect/lib/movies_connector/movies.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ part 'delete_review.dart';
1616

1717
part 'list_movies.dart';
1818

19+
part 'list_genres.dart';
20+
1921
part 'get_movie_by_id.dart';
2022

2123
part 'get_actor_by_id.dart';
@@ -85,6 +87,11 @@ class MoviesConnector {
8587
}
8688

8789

90+
ListGenresVariablesBuilder listGenres () {
91+
return ListGenresVariablesBuilder(dataConnect, );
92+
}
93+
94+
8895
GetMovieByIdVariablesBuilder getMovieById ({required String id,}) {
8996
return GetMovieByIdVariablesBuilder(dataConnect, id: id,);
9097
}

dataconnect/dataconnect/schema/schema.gql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ type MovieActor @table(key: ["movie", "actor"]) {
7878
role: String! # "main" or "supporting"
7979
}
8080

81+
type Genre @view(sql: """
82+
SELECT DISTINCT genre from "movie"
83+
"""
84+
) {
85+
genre: String
86+
}
87+
8188
# Join table for many-to-many relationship for users and favorite movies
8289
# TODO: Fill out FavoriteMovie table
8390
type FavoriteMovie

dataconnect/firebase.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,13 @@
4040
},
4141
"dataconnect": {
4242
"source": "dataconnect"
43+
},
44+
"emulators": {
45+
"dataconnect": {
46+
"port": 9399
47+
},
48+
"auth": {
49+
"port": 9400
50+
}
4351
}
4452
}

dataconnect/lib/actor_detail.dart

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import 'package:dataconnect/movies_connector/movies.dart';
2+
import 'package:flutter/material.dart';
3+
4+
class ActorDetail extends StatefulWidget {
5+
const ActorDetail({super.key, required this.actorId});
6+
7+
final String actorId;
8+
9+
@override
10+
State<ActorDetail> createState() => _ActorDetailState();
11+
}
12+
13+
class _ActorDetailState extends State<ActorDetail> {
14+
bool loading = true;
15+
GetActorByIdActor? actor;
16+
@override
17+
void initState() {
18+
super.initState();
19+
MoviesConnector.instance
20+
.getActorById(id: widget.actorId)
21+
.execute()
22+
.then((value) {
23+
setState(() {
24+
loading = false;
25+
actor = value.data.actor;
26+
});
27+
});
28+
}
29+
30+
_buildActorInfo() {
31+
return [
32+
Align(
33+
alignment: Alignment.centerLeft,
34+
child: Container(
35+
child: Text(
36+
actor!.name,
37+
style: const TextStyle(fontSize: 30),
38+
),
39+
)),
40+
Row(
41+
mainAxisAlignment: MainAxisAlignment.start,
42+
crossAxisAlignment: CrossAxisAlignment.start,
43+
children: [
44+
Expanded(
45+
child: AspectRatio(
46+
aspectRatio: 9 / 16, // 9:16 aspect ratio for the image
47+
child: Image.network(
48+
actor!.imageUrl,
49+
fit: BoxFit.cover,
50+
),
51+
),
52+
),
53+
Expanded(
54+
child: Padding(
55+
padding: const EdgeInsets.fromLTRB(15, 0, 0, 0),
56+
// child: Column(children: [Text(actor!.info!)]),
57+
))
58+
]),
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+
)
72+
];
73+
}
74+
75+
@override
76+
Widget build(BuildContext context) {
77+
return Scaffold(
78+
body: SafeArea(
79+
child: actor == null
80+
? const Column(
81+
mainAxisAlignment: MainAxisAlignment.center,
82+
crossAxisAlignment: CrossAxisAlignment.center,
83+
children: [CircularProgressIndicator()],
84+
)
85+
: Padding(
86+
padding: const EdgeInsets.all(30),
87+
child: SingleChildScrollView(
88+
child: Column(
89+
children: [..._buildActorInfo()],
90+
)))),
91+
);
92+
}
93+
}

dataconnect/lib/destination.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Destination {
4+
const Destination({required this.label, required this.icon});
5+
final String label;
6+
final IconData icon;
7+
}
8+
9+
class Route {
10+
Route({required this.path, required this.label, required this.iconData});
11+
final String path;
12+
final String label;
13+
final IconData iconData;
14+
}
15+
16+
var homePath = Route(path: '/home', label: 'Home', iconData: Icons.home);
17+
var genrePath = Route(path: '/genres', label: 'Genres', iconData: Icons.list);
18+
var searchPath =
19+
Route(path: '/search', label: 'Search', iconData: Icons.search);
20+
var profilePath =
21+
Route(path: '/profile', label: 'Profile', iconData: Icons.person);
22+
var paths = [homePath, genrePath, searchPath, profilePath];

0 commit comments

Comments
 (0)