Skip to content

Commit

Permalink
Added detail and signin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
maneesht committed Nov 14, 2024
1 parent c20034c commit 2ec2e2f
Show file tree
Hide file tree
Showing 25 changed files with 1,510 additions and 99 deletions.
1 change: 1 addition & 0 deletions dataconnect/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<application
android:label="dataconnect"
android:name="${applicationName}"
android:networkSecurityConfig="@xml/network_security_config"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
56 changes: 56 additions & 0 deletions dataconnect/dataconnect/.dataconnect/schema/main/input.gql
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,62 @@ input FavoriteMovie_Order {
user: User_Order
}
"""
✨ Generated filter input type for table 'Genre'. This input allows filtering objects using various conditions. Use `_or`, `_and`, and `_not` to compose complex filters.
"""
input Genre_Filter {
"""
Apply multiple filter conditions using `AND` logic.
"""
_and: [Genre_Filter!]
"""
Negate the result of the provided filter condition.
"""
_not: Genre_Filter
"""
Apply multiple filter conditions using `OR` logic.
"""
_or: [Genre_Filter!]
"""
✨ Generated from Field `Genre`.`genre` of type `String`
"""
genre: String_Filter
}
"""
✨ Generated first-row input type for table 'Genre'. This input selects the first row matching the filter criteria, ordered according to the specified conditions.
"""
input Genre_FirstRow {
"""
Order the result by the specified fields.
"""
orderBy: [Genre_Order!]
"""
Filters rows based on the specified conditions.
"""
where: Genre_Filter
}
"""
✨ 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.
"""
input Genre_ListFilter {
"""
The desired number of objects that match the condition (defaults to at least one).
"""
count: Int_Filter = {gt:0}
"""
Condition of the related objects to filter for.
"""
exist: Genre_Filter
}
"""
✨ Generated order input type for table 'Genre'. This input defines the sorting order of rows in query results based on one or more fields.
"""
input Genre_Order {
"""
✨ Generated from Field `Genre`.`genre` of type `String`
"""
genre: OrderDirection
}
"""
✨ Generated data input type for table 'Movie'. It includes all necessary fields for creating or upserting rows into table.
"""
input Movie_Data {
Expand Down
24 changes: 24 additions & 0 deletions dataconnect/dataconnect/.dataconnect/schema/main/query.gql
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ extend type Query {
limit: Int = 100
): [FavoriteMovie!]! @fdc_generated(from: "FavoriteMovie", purpose: QUERY_MULTIPLE)
"""
✨ List `Genre` objects in the table, optionally filtered by `where` conditions.
"""
genres(
"""
Filter condition to narrow down the query results.
"""
where: Genre_Filter

"""
Order the query results by specific fields.
"""
orderBy: [Genre_Order!]

"""
Number of rows to skip before starting to return the results.
"""
offset: Int

"""
Maximum number of rows to return (defaults to 100 rows).
"""
limit: Int = 100
): [Genre!]! @fdc_generated(from: "Genre", purpose: QUERY_MULTIPLE)
"""
✨ List `Movie` objects in the table, optionally filtered by `where` conditions.
"""
movies(
Expand Down
2 changes: 1 addition & 1 deletion dataconnect/dataconnect/connector/connector.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
connectorId: movies
generate:
dartSdk:
outputDir: ../lib/movies_connector
outputDir: ../../lib/movies_connector
package: movies_connector
26 changes: 26 additions & 0 deletions dataconnect/dataconnect/connector/queries.gql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ query ListMovies($orderByRating: OrderDirection, $orderByReleaseYear: OrderDirec
description
}
}
query ListMoviesByGenre($genre: String!, $orderByRating: OrderDirection, $orderByReleaseYear: OrderDirection, $limit: Int) @auth(level: PUBLIC) {
movies(where: {
genre: {
eq: $genre
}
}, orderBy: [
{ rating: $orderByRating },
{ releaseYear: $orderByReleaseYear }
]
limit: $limit) {
id
title
imageUrl
releaseYear
genre
rating
tags
description
}
}

query ListGenres @auth(level: PUBLIC) {
genres {
genre
}
}

# Get movie by id
query GetMovieById($id: UUID!) @auth(level: PUBLIC) {
Expand Down
7 changes: 7 additions & 0 deletions dataconnect/dataconnect/lib/movies_connector/movies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ part 'delete_review.dart';

part 'list_movies.dart';

part 'list_genres.dart';

part 'get_movie_by_id.dart';

part 'get_actor_by_id.dart';
Expand Down Expand Up @@ -85,6 +87,11 @@ class MoviesConnector {
}


ListGenresVariablesBuilder listGenres () {
return ListGenresVariablesBuilder(dataConnect, );
}


GetMovieByIdVariablesBuilder getMovieById ({required String id,}) {
return GetMovieByIdVariablesBuilder(dataConnect, id: id,);
}
Expand Down
7 changes: 7 additions & 0 deletions dataconnect/dataconnect/schema/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ type MovieActor @table(key: ["movie", "actor"]) {
role: String! # "main" or "supporting"
}

type Genre @view(sql: """
SELECT DISTINCT genre from "movie"
"""
) {
genre: String
}

# Join table for many-to-many relationship for users and favorite movies
# TODO: Fill out FavoriteMovie table
type FavoriteMovie
Expand Down
8 changes: 8 additions & 0 deletions dataconnect/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,13 @@
},
"dataconnect": {
"source": "dataconnect"
},
"emulators": {
"dataconnect": {
"port": 9399
},
"auth": {
"port": 9400
}
}
}
93 changes: 93 additions & 0 deletions dataconnect/lib/actor_detail.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import 'package:dataconnect/movies_connector/movies.dart';
import 'package:flutter/material.dart';

class ActorDetail extends StatefulWidget {
const ActorDetail({super.key, required this.actorId});

final String actorId;

@override
State<ActorDetail> createState() => _ActorDetailState();
}

class _ActorDetailState extends State<ActorDetail> {
bool loading = true;
GetActorByIdActor? actor;
@override
void initState() {
super.initState();
MoviesConnector.instance
.getActorById(id: widget.actorId)
.execute()
.then((value) {
setState(() {
loading = false;
actor = value.data.actor;
});
});
}

_buildActorInfo() {
return [
Align(
alignment: Alignment.centerLeft,
child: Container(
child: Text(
actor!.name,
style: const TextStyle(fontSize: 30),
),
)),
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: AspectRatio(
aspectRatio: 9 / 16, // 9:16 aspect ratio for the image
child: Image.network(
actor!.imageUrl,
fit: BoxFit.cover,
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(15, 0, 0, 0),
// child: Column(children: [Text(actor!.info!)]),
))
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// TODO(mtewani): Check if the movie has been watched by the user
OutlinedButton.icon(
onPressed: () {
// TODO(mtewani): Check if user is logged in.
},
icon: const Icon(Icons.favorite),
label: const Text('Add To Favorites'),
)
],
)
];
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: actor == null
? const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [CircularProgressIndicator()],
)
: Padding(
padding: const EdgeInsets.all(30),
child: SingleChildScrollView(
child: Column(
children: [..._buildActorInfo()],
)))),
);
}
}
22 changes: 22 additions & 0 deletions dataconnect/lib/destination.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';

class Destination {
const Destination({required this.label, required this.icon});
final String label;
final IconData icon;
}

class Route {
Route({required this.path, required this.label, required this.iconData});
final String path;
final String label;
final IconData iconData;
}

var homePath = Route(path: '/home', label: 'Home', iconData: Icons.home);
var genrePath = Route(path: '/genres', label: 'Genres', iconData: Icons.list);
var searchPath =
Route(path: '/search', label: 'Search', iconData: Icons.search);
var profilePath =
Route(path: '/profile', label: 'Profile', iconData: Icons.person);
var paths = [homePath, genrePath, searchPath, profilePath];
Loading

0 comments on commit 2ec2e2f

Please sign in to comment.