From f555797f315c2bfad44861e3c0c3ba49d18f8c1b Mon Sep 17 00:00:00 2001 From: Maneesh Tewani Date: Thu, 14 Nov 2024 15:19:20 -0800 Subject: [PATCH] Added signin/signup pages --- .../main/res/xml/network_security_config.xml | 6 + .../.dataconnect/schema/main/implicit.gql | 20 + .../.dataconnect/schema/main/input.gql | 320 ++++++ .../.dataconnect/schema/main/mutation.gql | 204 ++++ .../.dataconnect/schema/main/query.gql | 76 ++ .../.dataconnect/schema/main/relation.gql | 192 ++++ .../dataconnect/connector/mutations.gql | 14 +- dataconnect/dataconnect/connector/queries.gql | 50 +- .../movies_connector/add_favorited_movie.dart | 192 ---- .../lib/movies_connector/add_review.dart | 240 ---- .../delete_favorited_movie.dart | 194 ---- .../lib/movies_connector/get_actor_by_id.dart | 573 --------- .../movies_connector/get_current_user.dart | 763 ------------ .../get_if_favorited_movie.dart | 171 --- .../lib/movies_connector/get_movie_by_id.dart | 912 --------------- .../lib/movies_connector/list_movies.dart | 403 ------- .../lib/movies_connector/movies.dart | 136 --- .../lib/movies_connector/search_all.dart | 1021 ----------------- .../lib/movies_connector/update_review.dart | 242 ---- .../lib/movies_connector/upsert_user.dart | 169 --- dataconnect/dataconnect/moviedata_insert.gql | 6 +- dataconnect/dataconnect/schema/schema.gql | 13 + dataconnect/lib/extensions.dart | 49 + dataconnect/lib/login.dart | 3 + dataconnect/lib/movie_detail.dart | 107 +- .../lib/movies_connector/add_review.dart | 18 +- .../delete_favorited_actor.dart | 194 ++++ .../delete_watched_movie.dart} | 48 +- .../movies_connector/get_current_user.dart | 570 +++++++++ .../get_if_favorited_movie.dart | 171 --- .../get_movie_info_for_user.dart | 243 ++++ .../list_movies_by_partial_title.dart | 271 +++++ dataconnect/lib/movies_connector/movies.dart | 31 +- .../lib/movies_connector/upsert_user.dart | 28 +- dataconnect/lib/profile.dart | 42 +- dataconnect/lib/router.dart | 6 +- dataconnect/lib/search.dart | 270 +++++ dataconnect/lib/sign_up.dart | 24 +- dataconnect/lib/util/auth.dart | 13 +- dataconnect/lib/widgets/list_actors.dart | 64 ++ dataconnect/lib/widgets/list_movies.dart | 91 ++ dataconnect/lib/widgets/login_guard.dart | 38 + 42 files changed, 2912 insertions(+), 5286 deletions(-) create mode 100644 dataconnect/android/app/src/main/res/xml/network_security_config.xml delete mode 100644 dataconnect/dataconnect/lib/movies_connector/add_favorited_movie.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/add_review.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/delete_favorited_movie.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/get_actor_by_id.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/get_current_user.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/get_if_favorited_movie.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/get_movie_by_id.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/list_movies.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/movies.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/search_all.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/update_review.dart delete mode 100644 dataconnect/dataconnect/lib/movies_connector/upsert_user.dart create mode 100644 dataconnect/lib/extensions.dart create mode 100644 dataconnect/lib/movies_connector/delete_favorited_actor.dart rename dataconnect/{dataconnect/lib/movies_connector/delete_review.dart => lib/movies_connector/delete_watched_movie.dart} (50%) delete mode 100644 dataconnect/lib/movies_connector/get_if_favorited_movie.dart create mode 100644 dataconnect/lib/movies_connector/get_movie_info_for_user.dart create mode 100644 dataconnect/lib/movies_connector/list_movies_by_partial_title.dart create mode 100644 dataconnect/lib/search.dart create mode 100644 dataconnect/lib/widgets/list_actors.dart create mode 100644 dataconnect/lib/widgets/list_movies.dart create mode 100644 dataconnect/lib/widgets/login_guard.dart diff --git a/dataconnect/android/app/src/main/res/xml/network_security_config.xml b/dataconnect/android/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 00000000..17abf3ac --- /dev/null +++ b/dataconnect/android/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,6 @@ + + + + 10.0.2.2 + + \ No newline at end of file diff --git a/dataconnect/dataconnect/.dataconnect/schema/main/implicit.gql b/dataconnect/dataconnect/.dataconnect/schema/main/implicit.gql index c7944ef7..a63e2f15 100644 --- a/dataconnect/dataconnect/.dataconnect/schema/main/implicit.gql +++ b/dataconnect/dataconnect/.dataconnect/schema/main/implicit.gql @@ -1,3 +1,13 @@ +extend type FavoriteActor { + """ + ✨ Implicit foreign key field based on `FavoriteActor`.`user`. It must match the value of `User`.`id`. See `@ref` for how to customize it. + """ + userId: String! @fdc_generated(from: "FavoriteActor.user", purpose: IMPLICIT_REF_FIELD) + """ + ✨ Implicit foreign key field based on `FavoriteActor`.`actor`. It must match the value of `Actor`.`id`. See `@ref` for how to customize it. + """ + actorId: UUID! @fdc_generated(from: "FavoriteActor.actor", purpose: IMPLICIT_REF_FIELD) +} extend type FavoriteMovie { """ ✨ Implicit foreign key field based on `FavoriteMovie`.`user`. It must match the value of `User`.`id`. See `@ref` for how to customize it. @@ -38,3 +48,13 @@ extend type Review { """ userId: String! @fdc_generated(from: "Review.user", purpose: IMPLICIT_REF_FIELD) } +extend type WatchedMovie { + """ + ✨ Implicit foreign key field based on `WatchedMovie`.`user`. It must match the value of `User`.`id`. See `@ref` for how to customize it. + """ + userId: String! @fdc_generated(from: "WatchedMovie.user", purpose: IMPLICIT_REF_FIELD) + """ + ✨ Implicit foreign key field based on `WatchedMovie`.`movie`. It must match the value of `Movie`.`id`. See `@ref` for how to customize it. + """ + movieId: UUID! @fdc_generated(from: "WatchedMovie.movie", purpose: IMPLICIT_REF_FIELD) +} diff --git a/dataconnect/dataconnect/.dataconnect/schema/main/input.gql b/dataconnect/dataconnect/.dataconnect/schema/main/input.gql index 68d92f7e..8fae7303 100644 --- a/dataconnect/dataconnect/.dataconnect/schema/main/input.gql +++ b/dataconnect/dataconnect/.dataconnect/schema/main/input.gql @@ -5,6 +5,12 @@ It has the same format as `Actor_Key`, but is only used as mutation return value """ scalar Actor_KeyOutput """ +✨ `FavoriteActor_KeyOutput` returns the primary key fields of table type `FavoriteActor`. + +It has the same format as `FavoriteActor_Key`, but is only used as mutation return value. +""" +scalar FavoriteActor_KeyOutput +""" ✨ `FavoriteMovie_KeyOutput` returns the primary key fields of table type `FavoriteMovie`. It has the same format as `FavoriteMovie_Key`, but is only used as mutation return value. @@ -41,6 +47,12 @@ It has the same format as `User_Key`, but is only used as mutation return value. """ scalar User_KeyOutput """ +✨ `WatchedMovie_KeyOutput` returns the primary key fields of table type `WatchedMovie`. + +It has the same format as `WatchedMovie_Key`, but is only used as mutation return value. +""" +scalar WatchedMovie_KeyOutput +""" ✨ Generated data input type for table 'Actor'. It includes all necessary fields for creating or upserting rows into table. """ input Actor_Data { @@ -98,6 +110,10 @@ input Actor_Filter { """ name: String_Filter """ + ✨ Generated from Field `Actor`.`favorite_actors_on_actor` of type `[FavoriteActor!]!` + """ + favorite_actors_on_actor: FavoriteActor_ListFilter + """ ✨ Generated from Field `Actor`.`movieActors_on_actor` of type `[MovieActor!]!` """ movieActors_on_actor: MovieActor_ListFilter @@ -105,6 +121,10 @@ input Actor_Filter { ✨ Generated from Field `Actor`.`movies_via_MovieActor` of type `[Movie!]!` """ movies_via_MovieActor: Movie_ListFilter + """ + ✨ Generated from Field `Actor`.`users_via_FavoriteActor` of type `[User!]!` + """ + users_via_FavoriteActor: User_ListFilter } """ ✨ Generated first-row input type for table 'Actor'. This input selects the first row matching the filter criteria, ordered according to the specified conditions. @@ -163,6 +183,136 @@ input Actor_Order { name: OrderDirection } """ +✨ Generated data input type for table 'FavoriteActor'. It includes all necessary fields for creating or upserting rows into table. +""" +input FavoriteActor_Data { + """ + ✨ Generated from Field `FavoriteActor`.`userId` of type `String!` + """ + userId: String + """ + ✨ `_expr` server value variant of `userId` (✨ Generated from Field `FavoriteActor`.`userId` of type `String!`) + """ + userId_expr: String_Expr + """ + ✨ Generated from Field `FavoriteActor`.`actorId` of type `UUID!` + """ + actorId: UUID + """ + ✨ `_expr` server value variant of `actorId` (✨ Generated from Field `FavoriteActor`.`actorId` of type `UUID!`) + """ + actorId_expr: UUID_Expr + """ + ✨ Generated from Field `FavoriteActor`.`actor` of type `Actor!` + """ + actor: Actor_Key + """ + ✨ Generated from Field `FavoriteActor`.`user` of type `User!` + """ + user: User_Key +} +""" +✨ Generated filter input type for table 'FavoriteActor'. This input allows filtering objects using various conditions. Use `_or`, `_and`, and `_not` to compose complex filters. +""" +input FavoriteActor_Filter { + """ + Apply multiple filter conditions using `AND` logic. + """ + _and: [FavoriteActor_Filter!] + """ + Negate the result of the provided filter condition. + """ + _not: FavoriteActor_Filter + """ + Apply multiple filter conditions using `OR` logic. + """ + _or: [FavoriteActor_Filter!] + """ + ✨ Generated from Field `FavoriteActor`.`userId` of type `String!` + """ + userId: String_Filter + """ + ✨ Generated from Field `FavoriteActor`.`actorId` of type `UUID!` + """ + actorId: UUID_Filter + """ + ✨ Generated from Field `FavoriteActor`.`actor` of type `Actor!` + """ + actor: Actor_Filter + """ + ✨ Generated from Field `FavoriteActor`.`user` of type `User!` + """ + user: User_Filter +} +""" +✨ Generated first-row input type for table 'FavoriteActor'. This input selects the first row matching the filter criteria, ordered according to the specified conditions. +""" +input FavoriteActor_FirstRow { + """ + Order the result by the specified fields. + """ + orderBy: [FavoriteActor_Order!] + """ + Filters rows based on the specified conditions. + """ + where: FavoriteActor_Filter +} +""" +✨ Generated key input type for table 'FavoriteActor'. It represents the primary key fields used to uniquely identify a row in the table. +""" +input FavoriteActor_Key { + """ + ✨ Generated from Field `FavoriteActor`.`userId` of type `String!` + """ + userId: String + """ + ✨ `_expr` server value variant of `userId` (✨ Generated from Field `FavoriteActor`.`userId` of type `String!`) + """ + userId_expr: String_Expr + """ + ✨ Generated from Field `FavoriteActor`.`actorId` of type `UUID!` + """ + actorId: UUID + """ + ✨ `_expr` server value variant of `actorId` (✨ Generated from Field `FavoriteActor`.`actorId` of type `UUID!`) + """ + actorId_expr: UUID_Expr +} +""" +✨ Generated list filter input type for table 'FavoriteActor'. This input applies filtering logic based on the count or existence of related objects that matches certain criteria. +""" +input FavoriteActor_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: FavoriteActor_Filter +} +""" +✨ Generated order input type for table 'FavoriteActor'. This input defines the sorting order of rows in query results based on one or more fields. +""" +input FavoriteActor_Order { + """ + ✨ Generated from Field `FavoriteActor`.`userId` of type `String!` + """ + userId: OrderDirection + """ + ✨ Generated from Field `FavoriteActor`.`actorId` of type `UUID!` + """ + actorId: OrderDirection + """ + ✨ Generated from Field `FavoriteActor`.`actor` of type `Actor!` + """ + actor: Actor_Order + """ + ✨ Generated from Field `FavoriteActor`.`user` of type `User!` + """ + user: User_Order +} +""" ✨ Generated data input type for table 'FavoriteMovie'. It includes all necessary fields for creating or upserting rows into table. """ input FavoriteMovie_Data { @@ -470,6 +620,10 @@ input Movie_Filter { """ reviews_on_movie: Review_ListFilter """ + ✨ Generated from Field `Movie`.`watched_movies_on_movie` of type `[WatchedMovie!]!` + """ + watched_movies_on_movie: WatchedMovie_ListFilter + """ ✨ Generated from Field `Movie`.`actors_via_MovieActor` of type `[Actor!]!` """ actors_via_MovieActor: Actor_ListFilter @@ -481,6 +635,10 @@ input Movie_Filter { ✨ Generated from Field `Movie`.`users_via_Review` of type `[User!]!` """ users_via_Review: User_ListFilter + """ + ✨ Generated from Field `Movie`.`users_via_WatchedMovie` of type `[User!]!` + """ + users_via_WatchedMovie: User_ListFilter } """ ✨ Generated first-row input type for table 'Movie'. This input selects the first row matching the filter criteria, ordered according to the specified conditions. @@ -1033,6 +1191,14 @@ input User_Data { """ id_expr: String_Expr """ + ✨ Generated from Field `User`.`name` of type `String!` + """ + name: String + """ + ✨ `_expr` server value variant of `name` (✨ Generated from Field `User`.`name` of type `String!`) + """ + name_expr: String_Expr + """ ✨ Generated from Field `User`.`username` of type `String!` """ username: String @@ -1062,10 +1228,18 @@ input User_Filter { """ id: String_Filter """ + ✨ Generated from Field `User`.`name` of type `String!` + """ + name: String_Filter + """ ✨ Generated from Field `User`.`username` of type `String!` """ username: String_Filter """ + ✨ Generated from Field `User`.`favorite_actors_on_user` of type `[FavoriteActor!]!` + """ + favorite_actors_on_user: FavoriteActor_ListFilter + """ ✨ Generated from Field `User`.`favorite_movies_on_user` of type `[FavoriteMovie!]!` """ favorite_movies_on_user: FavoriteMovie_ListFilter @@ -1074,6 +1248,14 @@ input User_Filter { """ reviews_on_user: Review_ListFilter """ + ✨ Generated from Field `User`.`watched_movies_on_user` of type `[WatchedMovie!]!` + """ + watched_movies_on_user: WatchedMovie_ListFilter + """ + ✨ Generated from Field `User`.`actors_via_FavoriteActor` of type `[Actor!]!` + """ + actors_via_FavoriteActor: Actor_ListFilter + """ ✨ Generated from Field `User`.`movies_via_FavoriteMovie` of type `[Movie!]!` """ movies_via_FavoriteMovie: Movie_ListFilter @@ -1081,6 +1263,10 @@ input User_Filter { ✨ Generated from Field `User`.`movies_via_Review` of type `[Movie!]!` """ movies_via_Review: Movie_ListFilter + """ + ✨ Generated from Field `User`.`movies_via_WatchedMovie` of type `[Movie!]!` + """ + movies_via_WatchedMovie: Movie_ListFilter } """ ✨ Generated first-row input type for table 'User'. This input selects the first row matching the filter criteria, ordered according to the specified conditions. @@ -1130,7 +1316,141 @@ input User_Order { """ id: OrderDirection """ + ✨ Generated from Field `User`.`name` of type `String!` + """ + name: OrderDirection + """ ✨ Generated from Field `User`.`username` of type `String!` """ username: OrderDirection } +""" +✨ Generated data input type for table 'WatchedMovie'. It includes all necessary fields for creating or upserting rows into table. +""" +input WatchedMovie_Data { + """ + ✨ Generated from Field `WatchedMovie`.`userId` of type `String!` + """ + userId: String + """ + ✨ `_expr` server value variant of `userId` (✨ Generated from Field `WatchedMovie`.`userId` of type `String!`) + """ + userId_expr: String_Expr + """ + ✨ Generated from Field `WatchedMovie`.`movieId` of type `UUID!` + """ + movieId: UUID + """ + ✨ `_expr` server value variant of `movieId` (✨ Generated from Field `WatchedMovie`.`movieId` of type `UUID!`) + """ + movieId_expr: UUID_Expr + """ + ✨ Generated from Field `WatchedMovie`.`movie` of type `Movie!` + """ + movie: Movie_Key + """ + ✨ Generated from Field `WatchedMovie`.`user` of type `User!` + """ + user: User_Key +} +""" +✨ Generated filter input type for table 'WatchedMovie'. This input allows filtering objects using various conditions. Use `_or`, `_and`, and `_not` to compose complex filters. +""" +input WatchedMovie_Filter { + """ + Apply multiple filter conditions using `AND` logic. + """ + _and: [WatchedMovie_Filter!] + """ + Negate the result of the provided filter condition. + """ + _not: WatchedMovie_Filter + """ + Apply multiple filter conditions using `OR` logic. + """ + _or: [WatchedMovie_Filter!] + """ + ✨ Generated from Field `WatchedMovie`.`userId` of type `String!` + """ + userId: String_Filter + """ + ✨ Generated from Field `WatchedMovie`.`movieId` of type `UUID!` + """ + movieId: UUID_Filter + """ + ✨ Generated from Field `WatchedMovie`.`movie` of type `Movie!` + """ + movie: Movie_Filter + """ + ✨ Generated from Field `WatchedMovie`.`user` of type `User!` + """ + user: User_Filter +} +""" +✨ Generated first-row input type for table 'WatchedMovie'. This input selects the first row matching the filter criteria, ordered according to the specified conditions. +""" +input WatchedMovie_FirstRow { + """ + Order the result by the specified fields. + """ + orderBy: [WatchedMovie_Order!] + """ + Filters rows based on the specified conditions. + """ + where: WatchedMovie_Filter +} +""" +✨ Generated key input type for table 'WatchedMovie'. It represents the primary key fields used to uniquely identify a row in the table. +""" +input WatchedMovie_Key { + """ + ✨ Generated from Field `WatchedMovie`.`userId` of type `String!` + """ + userId: String + """ + ✨ `_expr` server value variant of `userId` (✨ Generated from Field `WatchedMovie`.`userId` of type `String!`) + """ + userId_expr: String_Expr + """ + ✨ Generated from Field `WatchedMovie`.`movieId` of type `UUID!` + """ + movieId: UUID + """ + ✨ `_expr` server value variant of `movieId` (✨ Generated from Field `WatchedMovie`.`movieId` of type `UUID!`) + """ + movieId_expr: UUID_Expr +} +""" +✨ Generated list filter input type for table 'WatchedMovie'. This input applies filtering logic based on the count or existence of related objects that matches certain criteria. +""" +input WatchedMovie_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: WatchedMovie_Filter +} +""" +✨ Generated order input type for table 'WatchedMovie'. This input defines the sorting order of rows in query results based on one or more fields. +""" +input WatchedMovie_Order { + """ + ✨ Generated from Field `WatchedMovie`.`userId` of type `String!` + """ + userId: OrderDirection + """ + ✨ Generated from Field `WatchedMovie`.`movieId` of type `UUID!` + """ + movieId: OrderDirection + """ + ✨ Generated from Field `WatchedMovie`.`movie` of type `Movie!` + """ + movie: Movie_Order + """ + ✨ Generated from Field `WatchedMovie`.`user` of type `User!` + """ + user: User_Order +} diff --git a/dataconnect/dataconnect/.dataconnect/schema/main/mutation.gql b/dataconnect/dataconnect/.dataconnect/schema/main/mutation.gql index 1dad2178..aacee812 100644 --- a/dataconnect/dataconnect/.dataconnect/schema/main/mutation.gql +++ b/dataconnect/dataconnect/.dataconnect/schema/main/mutation.gql @@ -9,6 +9,15 @@ extend type Mutation { data: Actor_Data! ): Actor_KeyOutput! @fdc_generated(from: "Actor", purpose: INSERT_SINGLE) """ + ✨ Insert a single `FavoriteActor` into the table. Columns not specified in `data` will receive defaults (e.g. `null`). + """ + favorite_actor_insert( + """ + Data object to insert into the table. + """ + data: FavoriteActor_Data! + ): FavoriteActor_KeyOutput! @fdc_generated(from: "FavoriteActor", purpose: INSERT_SINGLE) + """ ✨ Insert a single `FavoriteMovie` into the table. Columns not specified in `data` will receive defaults (e.g. `null`). """ favorite_movie_insert( @@ -63,6 +72,15 @@ extend type Mutation { data: User_Data! ): User_KeyOutput! @fdc_generated(from: "User", purpose: INSERT_SINGLE) """ + ✨ Insert a single `WatchedMovie` into the table. Columns not specified in `data` will receive defaults (e.g. `null`). + """ + watched_movie_insert( + """ + Data object to insert into the table. + """ + data: WatchedMovie_Data! + ): WatchedMovie_KeyOutput! @fdc_generated(from: "WatchedMovie", purpose: INSERT_SINGLE) + """ ✨ Insert `Actor` objects into the table. Columns not specified in `data` will receive defaults (e.g. `null`). """ actor_insertMany( @@ -72,6 +90,15 @@ extend type Mutation { data: [Actor_Data!]! ): [Actor_KeyOutput!]! @fdc_generated(from: "Actor", purpose: INSERT_MULTIPLE) """ + ✨ Insert `FavoriteActor` objects into the table. Columns not specified in `data` will receive defaults (e.g. `null`). + """ + favorite_actor_insertMany( + """ + List of data objects to insert into the table. + """ + data: [FavoriteActor_Data!]! + ): [FavoriteActor_KeyOutput!]! @fdc_generated(from: "FavoriteActor", purpose: INSERT_MULTIPLE) + """ ✨ Insert `FavoriteMovie` objects into the table. Columns not specified in `data` will receive defaults (e.g. `null`). """ favorite_movie_insertMany( @@ -126,6 +153,15 @@ extend type Mutation { data: [User_Data!]! ): [User_KeyOutput!]! @fdc_generated(from: "User", purpose: INSERT_MULTIPLE) """ + ✨ Insert `WatchedMovie` objects into the table. Columns not specified in `data` will receive defaults (e.g. `null`). + """ + watched_movie_insertMany( + """ + List of data objects to insert into the table. + """ + data: [WatchedMovie_Data!]! + ): [WatchedMovie_KeyOutput!]! @fdc_generated(from: "WatchedMovie", purpose: INSERT_MULTIPLE) + """ ✨ Insert or update a single `Actor` into the table, based on the primary key. Returns the key of the newly inserted `Actor`. """ actor_upsert( @@ -135,6 +171,15 @@ extend type Mutation { data: Actor_Data! ): Actor_KeyOutput! @fdc_generated(from: "Actor", purpose: UPSERT_SINGLE) """ + ✨ Insert or update a single `FavoriteActor` into the table, based on the primary key. Returns the key of the newly inserted `FavoriteActor`. + """ + favorite_actor_upsert( + """ + Data object to insert or update if it already exists. + """ + data: FavoriteActor_Data! + ): FavoriteActor_KeyOutput! @fdc_generated(from: "FavoriteActor", purpose: UPSERT_SINGLE) + """ ✨ Insert or update a single `FavoriteMovie` into the table, based on the primary key. Returns the key of the newly inserted `FavoriteMovie`. """ favorite_movie_upsert( @@ -189,6 +234,15 @@ extend type Mutation { data: User_Data! ): User_KeyOutput! @fdc_generated(from: "User", purpose: UPSERT_SINGLE) """ + ✨ Insert or update a single `WatchedMovie` into the table, based on the primary key. Returns the key of the newly inserted `WatchedMovie`. + """ + watched_movie_upsert( + """ + Data object to insert or update if it already exists. + """ + data: WatchedMovie_Data! + ): WatchedMovie_KeyOutput! @fdc_generated(from: "WatchedMovie", purpose: UPSERT_SINGLE) + """ ✨ Insert or update `Actor` objects into the table, based on the primary key. Returns the key of the newly inserted `Actor`. """ actor_upsertMany( @@ -198,6 +252,15 @@ extend type Mutation { data: [Actor_Data!]! ): [Actor_KeyOutput!]! @fdc_generated(from: "Actor", purpose: UPSERT_MULTIPLE) """ + ✨ Insert or update `FavoriteActor` objects into the table, based on the primary key. Returns the key of the newly inserted `FavoriteActor`. + """ + favorite_actor_upsertMany( + """ + List of data objects to insert or update if it already exists. + """ + data: [FavoriteActor_Data!]! + ): [FavoriteActor_KeyOutput!]! @fdc_generated(from: "FavoriteActor", purpose: UPSERT_MULTIPLE) + """ ✨ Insert or update `FavoriteMovie` objects into the table, based on the primary key. Returns the key of the newly inserted `FavoriteMovie`. """ favorite_movie_upsertMany( @@ -252,6 +315,15 @@ extend type Mutation { data: [User_Data!]! ): [User_KeyOutput!]! @fdc_generated(from: "User", purpose: UPSERT_MULTIPLE) """ + ✨ Insert or update `WatchedMovie` objects into the table, based on the primary key. Returns the key of the newly inserted `WatchedMovie`. + """ + watched_movie_upsertMany( + """ + List of data objects to insert or update if it already exists. + """ + data: [WatchedMovie_Data!]! + ): [WatchedMovie_KeyOutput!]! @fdc_generated(from: "WatchedMovie", purpose: UPSERT_MULTIPLE) + """ ✨ Update a single `Actor` based on `id`, `key` or `first`, setting columns specified in `data`. Returns `null` if not found. """ actor_update( @@ -276,6 +348,25 @@ extend type Mutation { data: Actor_Data! ): Actor_KeyOutput @fdc_generated(from: "Actor", purpose: UPDATE_SINGLE) """ + ✨ Update a single `FavoriteActor` based on `id`, `key` or `first`, setting columns specified in `data`. Returns `null` if not found. + """ + favorite_actor_update( + """ + The key used to identify the object. + """ + key: FavoriteActor_Key + + """ + Fetch the first row based on the filters and ordering. + """ + first: FavoriteActor_FirstRow + + """ + Data object containing fields to be updated. + """ + data: FavoriteActor_Data! + ): FavoriteActor_KeyOutput @fdc_generated(from: "FavoriteActor", purpose: UPDATE_SINGLE) + """ ✨ Update a single `FavoriteMovie` based on `id`, `key` or `first`, setting columns specified in `data`. Returns `null` if not found. """ favorite_movie_update( @@ -410,6 +501,25 @@ extend type Mutation { data: User_Data! ): User_KeyOutput @fdc_generated(from: "User", purpose: UPDATE_SINGLE) """ + ✨ Update a single `WatchedMovie` based on `id`, `key` or `first`, setting columns specified in `data`. Returns `null` if not found. + """ + watched_movie_update( + """ + The key used to identify the object. + """ + key: WatchedMovie_Key + + """ + Fetch the first row based on the filters and ordering. + """ + first: WatchedMovie_FirstRow + + """ + Data object containing fields to be updated. + """ + data: WatchedMovie_Data! + ): WatchedMovie_KeyOutput @fdc_generated(from: "WatchedMovie", purpose: UPDATE_SINGLE) + """ ✨ Update `Actor` objects matching `where` conditions (or `all`, if true) according to `data`. Returns the number of rows updated. """ actor_updateMany( @@ -429,6 +539,25 @@ extend type Mutation { data: Actor_Data! ): Int! @fdc_generated(from: "Actor", purpose: UPDATE_MULTIPLE) """ + ✨ Update `FavoriteActor` objects matching `where` conditions (or `all`, if true) according to `data`. Returns the number of rows updated. + """ + favorite_actor_updateMany( + """ + Filter condition to specify which rows to update. + """ + where: FavoriteActor_Filter + + """ + Set to true to update all rows. + """ + all: Boolean = false + + """ + Data object containing fields to update. + """ + data: FavoriteActor_Data! + ): Int! @fdc_generated(from: "FavoriteActor", purpose: UPDATE_MULTIPLE) + """ ✨ Update `FavoriteMovie` objects matching `where` conditions (or `all`, if true) according to `data`. Returns the number of rows updated. """ favorite_movie_updateMany( @@ -543,6 +672,25 @@ extend type Mutation { data: User_Data! ): Int! @fdc_generated(from: "User", purpose: UPDATE_MULTIPLE) """ + ✨ Update `WatchedMovie` objects matching `where` conditions (or `all`, if true) according to `data`. Returns the number of rows updated. + """ + watched_movie_updateMany( + """ + Filter condition to specify which rows to update. + """ + where: WatchedMovie_Filter + + """ + Set to true to update all rows. + """ + all: Boolean = false + + """ + Data object containing fields to update. + """ + data: WatchedMovie_Data! + ): Int! @fdc_generated(from: "WatchedMovie", purpose: UPDATE_MULTIPLE) + """ ✨ Delete a single `Actor` based on `id`, `key` or `first` and return its key (or `null` if not found). """ actor_delete( @@ -562,6 +710,20 @@ extend type Mutation { first: Actor_FirstRow ): Actor_KeyOutput @fdc_generated(from: "Actor", purpose: DELETE_SINGLE) """ + ✨ Delete a single `FavoriteActor` based on `id`, `key` or `first` and return its key (or `null` if not found). + """ + favorite_actor_delete( + """ + The key used to identify the object. + """ + key: FavoriteActor_Key + + """ + Fetch the first row based on the filters and ordering. + """ + first: FavoriteActor_FirstRow + ): FavoriteActor_KeyOutput @fdc_generated(from: "FavoriteActor", purpose: DELETE_SINGLE) + """ ✨ Delete a single `FavoriteMovie` based on `id`, `key` or `first` and return its key (or `null` if not found). """ favorite_movie_delete( @@ -666,6 +828,20 @@ extend type Mutation { first: User_FirstRow ): User_KeyOutput @fdc_generated(from: "User", purpose: DELETE_SINGLE) """ + ✨ Delete a single `WatchedMovie` based on `id`, `key` or `first` and return its key (or `null` if not found). + """ + watched_movie_delete( + """ + The key used to identify the object. + """ + key: WatchedMovie_Key + + """ + Fetch the first row based on the filters and ordering. + """ + first: WatchedMovie_FirstRow + ): WatchedMovie_KeyOutput @fdc_generated(from: "WatchedMovie", purpose: DELETE_SINGLE) + """ ✨ Delete `Actor` objects matching `where` conditions (or `all`, if true). Returns the number of rows deleted. """ actor_deleteMany( @@ -680,6 +856,20 @@ extend type Mutation { all: Boolean = false ): Int! @fdc_generated(from: "Actor", purpose: DELETE_MULTIPLE) """ + ✨ Delete `FavoriteActor` objects matching `where` conditions (or `all`, if true). Returns the number of rows deleted. + """ + favorite_actor_deleteMany( + """ + Filter condition to specify which rows to delete. + """ + where: FavoriteActor_Filter + + """ + Set to true to delete all rows. + """ + all: Boolean = false + ): Int! @fdc_generated(from: "FavoriteActor", purpose: DELETE_MULTIPLE) + """ ✨ Delete `FavoriteMovie` objects matching `where` conditions (or `all`, if true). Returns the number of rows deleted. """ favorite_movie_deleteMany( @@ -763,4 +953,18 @@ extend type Mutation { """ all: Boolean = false ): Int! @fdc_generated(from: "User", purpose: DELETE_MULTIPLE) + """ + ✨ Delete `WatchedMovie` objects matching `where` conditions (or `all`, if true). Returns the number of rows deleted. + """ + watched_movie_deleteMany( + """ + Filter condition to specify which rows to delete. + """ + where: WatchedMovie_Filter + + """ + Set to true to delete all rows. + """ + all: Boolean = false + ): Int! @fdc_generated(from: "WatchedMovie", purpose: DELETE_MULTIPLE) } diff --git a/dataconnect/dataconnect/.dataconnect/schema/main/query.gql b/dataconnect/dataconnect/.dataconnect/schema/main/query.gql index a2f3bc6f..ed0a411d 100644 --- a/dataconnect/dataconnect/.dataconnect/schema/main/query.gql +++ b/dataconnect/dataconnect/.dataconnect/schema/main/query.gql @@ -19,6 +19,20 @@ extend type Query { first: Actor_FirstRow ): Actor @fdc_generated(from: "Actor", purpose: QUERY_SINGLE) """ + ✨ Look up a single `FavoriteActor` based on `id`, `key` or `first` and return selected fields (or `null` if not found). + """ + favorite_actor( + """ + The key used to identify the object. + """ + key: FavoriteActor_Key + + """ + Fetch the first row based on the filters and ordering. + """ + first: FavoriteActor_FirstRow + ): FavoriteActor @fdc_generated(from: "FavoriteActor", purpose: QUERY_SINGLE) + """ ✨ Look up a single `FavoriteMovie` based on `id`, `key` or `first` and return selected fields (or `null` if not found). """ favorite_movie( @@ -123,6 +137,20 @@ extend type Query { first: User_FirstRow ): User @fdc_generated(from: "User", purpose: QUERY_SINGLE) """ + ✨ Look up a single `WatchedMovie` based on `id`, `key` or `first` and return selected fields (or `null` if not found). + """ + watched_movie( + """ + The key used to identify the object. + """ + key: WatchedMovie_Key + + """ + Fetch the first row based on the filters and ordering. + """ + first: WatchedMovie_FirstRow + ): WatchedMovie @fdc_generated(from: "WatchedMovie", purpose: QUERY_SINGLE) + """ ✨ List `Actor` objects in the table, optionally filtered by `where` conditions. """ actors( @@ -147,6 +175,30 @@ extend type Query { limit: Int = 100 ): [Actor!]! @fdc_generated(from: "Actor", purpose: QUERY_MULTIPLE) """ + ✨ List `FavoriteActor` objects in the table, optionally filtered by `where` conditions. + """ + favorite_actors( + """ + Filter condition to narrow down the query results. + """ + where: FavoriteActor_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [FavoriteActor_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 + ): [FavoriteActor!]! @fdc_generated(from: "FavoriteActor", purpose: QUERY_MULTIPLE) + """ ✨ List `FavoriteMovie` objects in the table, optionally filtered by `where` conditions. """ favorite_movies( @@ -314,4 +366,28 @@ extend type Query { """ limit: Int = 100 ): [User!]! @fdc_generated(from: "User", purpose: QUERY_MULTIPLE) + """ + ✨ List `WatchedMovie` objects in the table, optionally filtered by `where` conditions. + """ + watched_movies( + """ + Filter condition to narrow down the query results. + """ + where: WatchedMovie_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [WatchedMovie_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 + ): [WatchedMovie!]! @fdc_generated(from: "WatchedMovie", purpose: QUERY_MULTIPLE) } diff --git a/dataconnect/dataconnect/.dataconnect/schema/main/relation.gql b/dataconnect/dataconnect/.dataconnect/schema/main/relation.gql index 5b1d7799..9f73ee86 100644 --- a/dataconnect/dataconnect/.dataconnect/schema/main/relation.gql +++ b/dataconnect/dataconnect/.dataconnect/schema/main/relation.gql @@ -1,4 +1,28 @@ extend type Actor { + """ + ✨ List `FavoriteActor` objects in a one-to-many relationship (where `FavoriteActor`.`actor` is this object). + """ + favorite_actors_on_actor( + """ + Filter condition to narrow down the query results. + """ + where: FavoriteActor_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [FavoriteActor_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 + ): [FavoriteActor!]! @fdc_generated(from: "FavoriteActor.actor", purpose: QUERY_MULTIPLE_ONE_TO_MANY) """ ✨ List `MovieActor` objects in a one-to-many relationship (where `MovieActor`.`actor` is this object). """ @@ -47,6 +71,30 @@ extend type Actor { """ limit: Int = 100 ): [Movie!]! @fdc_generated(from: "MovieActor", purpose: QUERY_MULTIPLE_MANY_TO_MANY) + """ + ✨ List `User` objects using `FavoriteActor` as the join table (a `FavoriteActor` object exists where its `actor` is this and its `user` is that). + """ + users_via_FavoriteActor( + """ + Filter condition to narrow down the query results. + """ + where: FavoriteActor_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [FavoriteActor_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 + ): [User!]! @fdc_generated(from: "FavoriteActor", purpose: QUERY_MULTIPLE_MANY_TO_MANY) } extend type Movie { """ @@ -146,6 +194,30 @@ extend type Movie { limit: Int = 100 ): [Review!]! @fdc_generated(from: "Review.movie", purpose: QUERY_MULTIPLE_ONE_TO_MANY) """ + ✨ List `WatchedMovie` objects in a one-to-many relationship (where `WatchedMovie`.`movie` is this object). + """ + watched_movies_on_movie( + """ + Filter condition to narrow down the query results. + """ + where: WatchedMovie_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [WatchedMovie_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 + ): [WatchedMovie!]! @fdc_generated(from: "WatchedMovie.movie", purpose: QUERY_MULTIPLE_ONE_TO_MANY) + """ ✨ List `Actor` objects using `MovieActor` as the join table (a `MovieActor` object exists where its `movie` is this and its `actor` is that). """ actors_via_MovieActor( @@ -217,8 +289,56 @@ extend type Movie { """ limit: Int = 100 ): [User!]! @fdc_generated(from: "Review", purpose: QUERY_MULTIPLE_MANY_TO_MANY) + """ + ✨ List `User` objects using `WatchedMovie` as the join table (a `WatchedMovie` object exists where its `movie` is this and its `user` is that). + """ + users_via_WatchedMovie( + """ + Filter condition to narrow down the query results. + """ + where: WatchedMovie_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [WatchedMovie_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 + ): [User!]! @fdc_generated(from: "WatchedMovie", purpose: QUERY_MULTIPLE_MANY_TO_MANY) } extend type User { + """ + ✨ List `FavoriteActor` objects in a one-to-many relationship (where `FavoriteActor`.`user` is this object). + """ + favorite_actors_on_user( + """ + Filter condition to narrow down the query results. + """ + where: FavoriteActor_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [FavoriteActor_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 + ): [FavoriteActor!]! @fdc_generated(from: "FavoriteActor.user", purpose: QUERY_MULTIPLE_ONE_TO_MANY) """ ✨ List `FavoriteMovie` objects in a one-to-many relationship (where `FavoriteMovie`.`user` is this object). """ @@ -268,6 +388,54 @@ extend type User { limit: Int = 100 ): [Review!]! @fdc_generated(from: "Review.user", purpose: QUERY_MULTIPLE_ONE_TO_MANY) """ + ✨ List `WatchedMovie` objects in a one-to-many relationship (where `WatchedMovie`.`user` is this object). + """ + watched_movies_on_user( + """ + Filter condition to narrow down the query results. + """ + where: WatchedMovie_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [WatchedMovie_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 + ): [WatchedMovie!]! @fdc_generated(from: "WatchedMovie.user", purpose: QUERY_MULTIPLE_ONE_TO_MANY) + """ + ✨ List `Actor` objects using `FavoriteActor` as the join table (a `FavoriteActor` object exists where its `user` is this and its `actor` is that). + """ + actors_via_FavoriteActor( + """ + Filter condition to narrow down the query results. + """ + where: FavoriteActor_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [FavoriteActor_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 + ): [Actor!]! @fdc_generated(from: "FavoriteActor", purpose: QUERY_MULTIPLE_MANY_TO_MANY) + """ ✨ List `Movie` objects using `FavoriteMovie` as the join table (a `FavoriteMovie` object exists where its `user` is this and its `movie` is that). """ movies_via_FavoriteMovie( @@ -315,4 +483,28 @@ extend type User { """ limit: Int = 100 ): [Movie!]! @fdc_generated(from: "Review", purpose: QUERY_MULTIPLE_MANY_TO_MANY) + """ + ✨ List `Movie` objects using `WatchedMovie` as the join table (a `WatchedMovie` object exists where its `user` is this and its `movie` is that). + """ + movies_via_WatchedMovie( + """ + Filter condition to narrow down the query results. + """ + where: WatchedMovie_Filter + + """ + Order the query results by specific fields. + """ + orderBy: [WatchedMovie_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 + ): [Movie!]! @fdc_generated(from: "WatchedMovie", purpose: QUERY_MULTIPLE_MANY_TO_MANY) } diff --git a/dataconnect/dataconnect/connector/mutations.gql b/dataconnect/dataconnect/connector/mutations.gql index 0d7545e4..1498eeb4 100644 --- a/dataconnect/dataconnect/connector/mutations.gql +++ b/dataconnect/dataconnect/connector/mutations.gql @@ -1,8 +1,9 @@ -mutation UpsertUser($username: String!) @auth(level: USER) { +mutation UpsertUser($username: String!, $name: String!) @auth(level: USER) { user_upsert( data: { id_expr: "auth.uid" username: $username + name: $name } ) } @@ -12,15 +13,24 @@ mutation AddFavoritedMovie($movieId: UUID!) @auth(level: USER) { favorite_movie_upsert(data: { userId_expr: "auth.uid", movieId: $movieId }) } + # Remove a movie from the user's favorites list mutation DeleteFavoritedMovie($movieId: UUID!) @auth(level: USER) { favorite_movie_delete(key: { userId_expr: "auth.uid", movieId: $movieId }) } +# Add a movie to the user's favorites list +mutation DeleteFavoritedActor($actorId: UUID!) @auth(level: USER) { + favorite_actor_delete(key: { userId_expr: "auth.uid", actorId: $actorId }) +} +mutation DeleteWatchedMovie($movieId: UUID!) @auth(level: USER) { + watched_movie_delete(key: { userId_expr: "auth.uid", movieId: $movieId }) +} + # Add a review for a movie mutation AddReview($movieId: UUID!, $rating: Int!, $reviewText: String!) @auth(level: USER) { - review_insert( + review_upsert( data: { userId_expr: "auth.uid" movieId: $movieId diff --git a/dataconnect/dataconnect/connector/queries.gql b/dataconnect/dataconnect/connector/queries.gql index 67e09571..cd54b43d 100644 --- a/dataconnect/dataconnect/connector/queries.gql +++ b/dataconnect/dataconnect/connector/queries.gql @@ -114,6 +114,7 @@ query GetCurrentUser @auth(level: USER) { user(key: { id_expr: "auth.uid" }) { id username + name reviews: reviews_on_user { id rating @@ -139,15 +140,42 @@ query GetCurrentUser @auth(level: USER) { } } } + favoriteActors: favorite_actors_on_user { + actor { + id + name + imageUrl + } + } + watchedMovies: watched_movies_on_user { + movie { + id + title + genre + imageUrl + releaseYear + rating + description + tags + metadata: movieMetadatas_on_movie { + director + } + } + } + } } -query GetIfFavoritedMovie($movieId: UUID!) @auth(level: USER) { +query GetMovieInfoForUser($movieId: UUID!) @auth(level: USER) { favorite_movie(key: { userId_expr: "auth.uid", movieId: $movieId }) { movieId } + watched_movie(key: { userId_expr: "auth.uid", movieId: $movieId }) { + movieId + } } + # Search for movies, actors, and reviews query SearchAll( $input: String @@ -236,16 +264,16 @@ query SearchAll( # # The queries below are unused by the application, but are useful examples for more complex cases -# # List movies by partial title match -# query ListMoviesByPartialTitle($input: String!) @auth(level: PUBLIC) { -# movies(where: { title: { contains: $input } }) { -# id -# title -# genre -# rating -# imageUrl -# } -# } +# List movies by partial title match +query ListMoviesByPartialTitle($input: String!) @auth(level: PUBLIC) { + movies(where: { title: { contains: $input } }) { + id + title + genre + rating + imageUrl + } +} # # List movies by tag # query ListMoviesByTag($tag: String!) @auth(level: PUBLIC) { diff --git a/dataconnect/dataconnect/lib/movies_connector/add_favorited_movie.dart b/dataconnect/dataconnect/lib/movies_connector/add_favorited_movie.dart deleted file mode 100644 index 9f2a90b9..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/add_favorited_movie.dart +++ /dev/null @@ -1,192 +0,0 @@ -part of movies_connector; - -class AddFavoritedMovieVariablesBuilder { - String movieId; - - - FirebaseDataConnect _dataConnect; - - AddFavoritedMovieVariablesBuilder(this._dataConnect, {required String this.movieId,}); - Deserializer dataDeserializer = (dynamic json) => AddFavoritedMovieData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (AddFavoritedMovieVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - MutationRef ref() { - AddFavoritedMovieVariables vars=AddFavoritedMovieVariables(movieId: movieId,); - - return _dataConnect.mutation("AddFavoritedMovie", dataDeserializer, varsSerializer, vars); - } -} - - - class AddFavoritedMovieFavoriteMovieUpsert { - - String userId; - - - String movieId; - - - - - - - AddFavoritedMovieFavoriteMovieUpsert.fromJson(dynamic json): - userId = - - nativeFromJson(json['userId']) - - - - , - - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['userId'] = - - nativeToJson(userId) - -; - - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - AddFavoritedMovieFavoriteMovieUpsert({ - - required this.userId, - - required this.movieId, - - }); -} - - - - class AddFavoritedMovieData { - - AddFavoritedMovieFavoriteMovieUpsert favorite_movie_upsert; - - - - - - - AddFavoritedMovieData.fromJson(dynamic json): - favorite_movie_upsert = - - AddFavoritedMovieFavoriteMovieUpsert.fromJson(json['favorite_movie_upsert']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['favorite_movie_upsert'] = - - favorite_movie_upsert.toJson() - -; - - - return json; - } - - AddFavoritedMovieData({ - - required this.favorite_movie_upsert, - - }); -} - - - - class AddFavoritedMovieVariables { - - String movieId; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - AddFavoritedMovieVariables.fromJson(Map json): - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - AddFavoritedMovieVariables({ - - required this.movieId, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/add_review.dart b/dataconnect/dataconnect/lib/movies_connector/add_review.dart deleted file mode 100644 index 1205433f..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/add_review.dart +++ /dev/null @@ -1,240 +0,0 @@ -part of movies_connector; - -class AddReviewVariablesBuilder { - String movieId; -int rating; -String reviewText; - - - FirebaseDataConnect _dataConnect; - - AddReviewVariablesBuilder(this._dataConnect, {required String this.movieId,required int this.rating,required String this.reviewText,}); - Deserializer dataDeserializer = (dynamic json) => AddReviewData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (AddReviewVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - MutationRef ref() { - AddReviewVariables vars=AddReviewVariables(movieId: movieId,rating: rating,reviewText: reviewText,); - - return _dataConnect.mutation("AddReview", dataDeserializer, varsSerializer, vars); - } -} - - - class AddReviewReviewInsert { - - String userId; - - - String movieId; - - - - - - - AddReviewReviewInsert.fromJson(dynamic json): - userId = - - nativeFromJson(json['userId']) - - - - , - - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['userId'] = - - nativeToJson(userId) - -; - - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - AddReviewReviewInsert({ - - required this.userId, - - required this.movieId, - - }); -} - - - - class AddReviewData { - - AddReviewReviewInsert review_insert; - - - - - - - AddReviewData.fromJson(dynamic json): - review_insert = - - AddReviewReviewInsert.fromJson(json['review_insert']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['review_insert'] = - - review_insert.toJson() - -; - - - return json; - } - - AddReviewData({ - - required this.review_insert, - - }); -} - - - - class AddReviewVariables { - - String movieId; - - - int rating; - - - String reviewText; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - AddReviewVariables.fromJson(Map json): - movieId = - - nativeFromJson(json['movieId']) - - - - , - - rating = - - nativeFromJson(json['rating']) - - - - , - - reviewText = - - nativeFromJson(json['reviewText']) - - - - - { - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - - json['rating'] = - - nativeToJson(rating) - -; - - - - json['reviewText'] = - - nativeToJson(reviewText) - -; - - - return json; - } - - AddReviewVariables({ - - required this.movieId, - - required this.rating, - - required this.reviewText, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/delete_favorited_movie.dart b/dataconnect/dataconnect/lib/movies_connector/delete_favorited_movie.dart deleted file mode 100644 index 2071ee5d..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/delete_favorited_movie.dart +++ /dev/null @@ -1,194 +0,0 @@ -part of movies_connector; - -class DeleteFavoritedMovieVariablesBuilder { - String movieId; - - - FirebaseDataConnect _dataConnect; - - DeleteFavoritedMovieVariablesBuilder(this._dataConnect, {required String this.movieId,}); - Deserializer dataDeserializer = (dynamic json) => DeleteFavoritedMovieData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (DeleteFavoritedMovieVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - MutationRef ref() { - DeleteFavoritedMovieVariables vars=DeleteFavoritedMovieVariables(movieId: movieId,); - - return _dataConnect.mutation("DeleteFavoritedMovie", dataDeserializer, varsSerializer, vars); - } -} - - - class DeleteFavoritedMovieFavoriteMovieDelete { - - String userId; - - - String movieId; - - - - - - - DeleteFavoritedMovieFavoriteMovieDelete.fromJson(dynamic json): - userId = - - nativeFromJson(json['userId']) - - - - , - - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['userId'] = - - nativeToJson(userId) - -; - - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - DeleteFavoritedMovieFavoriteMovieDelete({ - - required this.userId, - - required this.movieId, - - }); -} - - - - class DeleteFavoritedMovieData { - - DeleteFavoritedMovieFavoriteMovieDelete? favorite_movie_delete; - - - - - - - DeleteFavoritedMovieData.fromJson(dynamic json): - favorite_movie_delete = json['favorite_movie_delete'] == null ? null : - - DeleteFavoritedMovieFavoriteMovieDelete.fromJson(json['favorite_movie_delete']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (favorite_movie_delete != null) { - json['favorite_movie_delete'] = - - favorite_movie_delete!.toJson() - -; - } - - - return json; - } - - DeleteFavoritedMovieData({ - - this.favorite_movie_delete, - - }); -} - - - - class DeleteFavoritedMovieVariables { - - String movieId; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - DeleteFavoritedMovieVariables.fromJson(Map json): - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - DeleteFavoritedMovieVariables({ - - required this.movieId, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/get_actor_by_id.dart b/dataconnect/dataconnect/lib/movies_connector/get_actor_by_id.dart deleted file mode 100644 index 5400fa07..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/get_actor_by_id.dart +++ /dev/null @@ -1,573 +0,0 @@ -part of movies_connector; - -class GetActorByIdVariablesBuilder { - String id; - - - FirebaseDataConnect _dataConnect; - - GetActorByIdVariablesBuilder(this._dataConnect, {required String this.id,}); - Deserializer dataDeserializer = (dynamic json) => GetActorByIdData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (GetActorByIdVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - GetActorByIdVariables vars=GetActorByIdVariables(id: id,); - - return _dataConnect.query("GetActorById", dataDeserializer, varsSerializer, vars); - } -} - - - class GetActorByIdActor { - - String id; - - - String name; - - - String imageUrl; - - - List mainActors; - - - List supportingActors; - - - - - - - GetActorByIdActor.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - name = - - nativeFromJson(json['name']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - , - - mainActors = - - - (json['mainActors'] as List) - .map((e) => GetActorByIdActorMainActors.fromJson(e)) - .toList() - - - - - , - - supportingActors = - - - (json['supportingActors'] as List) - .map((e) => GetActorByIdActorSupportingActors.fromJson(e)) - .toList() - - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['name'] = - - nativeToJson(name) - -; - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - - json['mainActors'] = - - - mainActors.map((e) => e.toJson()).toList() - - -; - - - - json['supportingActors'] = - - - supportingActors.map((e) => e.toJson()).toList() - - -; - - - return json; - } - - GetActorByIdActor({ - - required this.id, - - required this.name, - - required this.imageUrl, - - required this.mainActors, - - required this.supportingActors, - - }); -} - - - - class GetActorByIdActorMainActors { - - String id; - - - String title; - - - String? genre; - - - List? tags; - - - String imageUrl; - - - - - - - GetActorByIdActorMainActors.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - tags = json['tags'] == null ? null : - - - (json['tags'] as List) - .map((e) => nativeFromJson(e)) - .toList() - - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - if (tags != null) { - json['tags'] = - - - tags?.map((e) => nativeToJson(e)).toList() - - -; - } - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - GetActorByIdActorMainActors({ - - required this.id, - - required this.title, - - this.genre, - - this.tags, - - required this.imageUrl, - - }); -} - - - - class GetActorByIdActorSupportingActors { - - String id; - - - String title; - - - String? genre; - - - List? tags; - - - String imageUrl; - - - - - - - GetActorByIdActorSupportingActors.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - tags = json['tags'] == null ? null : - - - (json['tags'] as List) - .map((e) => nativeFromJson(e)) - .toList() - - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - if (tags != null) { - json['tags'] = - - - tags?.map((e) => nativeToJson(e)).toList() - - -; - } - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - GetActorByIdActorSupportingActors({ - - required this.id, - - required this.title, - - this.genre, - - this.tags, - - required this.imageUrl, - - }); -} - - - - class GetActorByIdData { - - GetActorByIdActor? actor; - - - - - - - GetActorByIdData.fromJson(dynamic json): - actor = json['actor'] == null ? null : - - GetActorByIdActor.fromJson(json['actor']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (actor != null) { - json['actor'] = - - actor!.toJson() - -; - } - - - return json; - } - - GetActorByIdData({ - - this.actor, - - }); -} - - - - class GetActorByIdVariables { - - String id; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - GetActorByIdVariables.fromJson(Map json): - id = - - nativeFromJson(json['id']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - return json; - } - - GetActorByIdVariables({ - - required this.id, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/get_current_user.dart b/dataconnect/dataconnect/lib/movies_connector/get_current_user.dart deleted file mode 100644 index 38a7e191..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/get_current_user.dart +++ /dev/null @@ -1,763 +0,0 @@ -part of movies_connector; - -class GetCurrentUserVariablesBuilder { - - - FirebaseDataConnect _dataConnect; - - GetCurrentUserVariablesBuilder(this._dataConnect, ); - Deserializer dataDeserializer = (dynamic json) => GetCurrentUserData.fromJson(jsonDecode(json)); - - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - - return _dataConnect.query("GetCurrentUser", dataDeserializer, emptySerializer, null); - } -} - - - class GetCurrentUserUser { - - String id; - - - String username; - - - List reviews; - - - List favoriteMovies; - - - - - - - GetCurrentUserUser.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - username = - - nativeFromJson(json['username']) - - - - , - - reviews = - - - (json['reviews'] as List) - .map((e) => GetCurrentUserUserReviews.fromJson(e)) - .toList() - - - - - , - - favoriteMovies = - - - (json['favoriteMovies'] as List) - .map((e) => GetCurrentUserUserFavoriteMovies.fromJson(e)) - .toList() - - - - - - { - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['username'] = - - nativeToJson(username) - -; - - - - json['reviews'] = - - - reviews.map((e) => e.toJson()).toList() - - -; - - - - json['favoriteMovies'] = - - - favoriteMovies.map((e) => e.toJson()).toList() - - -; - - - return json; - } - - GetCurrentUserUser({ - - required this.id, - - required this.username, - - required this.reviews, - - required this.favoriteMovies, - - }); -} - - - - class GetCurrentUserUserReviews { - - String id; - - - int? rating; - - - DateTime reviewDate; - - - String? reviewText; - - - GetCurrentUserUserReviewsMovie movie; - - - - - - - GetCurrentUserUserReviews.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - reviewDate = - - nativeFromJson(json['reviewDate']) - - - - , - - reviewText = json['reviewText'] == null ? null : - - nativeFromJson(json['reviewText']) - - - - , - - movie = - - GetCurrentUserUserReviewsMovie.fromJson(json['movie']) - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - json['reviewDate'] = - - nativeToJson(reviewDate) - -; - - - - if (reviewText != null) { - json['reviewText'] = - - nativeToJson(reviewText) - -; - } - - - - json['movie'] = - - movie.toJson() - -; - - - return json; - } - - GetCurrentUserUserReviews({ - - required this.id, - - this.rating, - - required this.reviewDate, - - this.reviewText, - - required this.movie, - - }); -} - - - - class GetCurrentUserUserReviewsMovie { - - String id; - - - String title; - - - - - - - GetCurrentUserUserReviewsMovie.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - return json; - } - - GetCurrentUserUserReviewsMovie({ - - required this.id, - - required this.title, - - }); -} - - - - class GetCurrentUserUserFavoriteMovies { - - GetCurrentUserUserFavoriteMoviesMovie movie; - - - - - - - GetCurrentUserUserFavoriteMovies.fromJson(dynamic json): - movie = - - GetCurrentUserUserFavoriteMoviesMovie.fromJson(json['movie']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movie'] = - - movie.toJson() - -; - - - return json; - } - - GetCurrentUserUserFavoriteMovies({ - - required this.movie, - - }); -} - - - - class GetCurrentUserUserFavoriteMoviesMovie { - - String id; - - - String title; - - - String? genre; - - - String imageUrl; - - - int? releaseYear; - - - double? rating; - - - String? description; - - - List? tags; - - - List metadata; - - - - - - - GetCurrentUserUserFavoriteMoviesMovie.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - , - - releaseYear = json['releaseYear'] == null ? null : - - nativeFromJson(json['releaseYear']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - description = json['description'] == null ? null : - - nativeFromJson(json['description']) - - - - , - - tags = json['tags'] == null ? null : - - - (json['tags'] as List) - .map((e) => nativeFromJson(e)) - .toList() - - - - - , - - metadata = - - - (json['metadata'] as List) - .map((e) => GetCurrentUserUserFavoriteMoviesMovieMetadata.fromJson(e)) - .toList() - - - - - - { - - - - - - - - - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - - if (releaseYear != null) { - json['releaseYear'] = - - nativeToJson(releaseYear) - -; - } - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - if (description != null) { - json['description'] = - - nativeToJson(description) - -; - } - - - - if (tags != null) { - json['tags'] = - - - tags?.map((e) => nativeToJson(e)).toList() - - -; - } - - - - json['metadata'] = - - - metadata.map((e) => e.toJson()).toList() - - -; - - - return json; - } - - GetCurrentUserUserFavoriteMoviesMovie({ - - required this.id, - - required this.title, - - this.genre, - - required this.imageUrl, - - this.releaseYear, - - this.rating, - - this.description, - - this.tags, - - required this.metadata, - - }); -} - - - - class GetCurrentUserUserFavoriteMoviesMovieMetadata { - - String? director; - - - - - - - GetCurrentUserUserFavoriteMoviesMovieMetadata.fromJson(dynamic json): - director = json['director'] == null ? null : - - nativeFromJson(json['director']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (director != null) { - json['director'] = - - nativeToJson(director) - -; - } - - - return json; - } - - GetCurrentUserUserFavoriteMoviesMovieMetadata({ - - this.director, - - }); -} - - - - class GetCurrentUserData { - - GetCurrentUserUser? user; - - - - - - - GetCurrentUserData.fromJson(dynamic json): - user = json['user'] == null ? null : - - GetCurrentUserUser.fromJson(json['user']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (user != null) { - json['user'] = - - user!.toJson() - -; - } - - - return json; - } - - GetCurrentUserData({ - - this.user, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/get_if_favorited_movie.dart b/dataconnect/dataconnect/lib/movies_connector/get_if_favorited_movie.dart deleted file mode 100644 index 901fb84e..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/get_if_favorited_movie.dart +++ /dev/null @@ -1,171 +0,0 @@ -part of movies_connector; - -class GetIfFavoritedMovieVariablesBuilder { - String movieId; - - - FirebaseDataConnect _dataConnect; - - GetIfFavoritedMovieVariablesBuilder(this._dataConnect, {required String this.movieId,}); - Deserializer dataDeserializer = (dynamic json) => GetIfFavoritedMovieData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (GetIfFavoritedMovieVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - GetIfFavoritedMovieVariables vars=GetIfFavoritedMovieVariables(movieId: movieId,); - - return _dataConnect.query("GetIfFavoritedMovie", dataDeserializer, varsSerializer, vars); - } -} - - - class GetIfFavoritedMovieFavoriteMovie { - - String movieId; - - - - - - - GetIfFavoritedMovieFavoriteMovie.fromJson(dynamic json): - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - GetIfFavoritedMovieFavoriteMovie({ - - required this.movieId, - - }); -} - - - - class GetIfFavoritedMovieData { - - GetIfFavoritedMovieFavoriteMovie? favorite_movie; - - - - - - - GetIfFavoritedMovieData.fromJson(dynamic json): - favorite_movie = json['favorite_movie'] == null ? null : - - GetIfFavoritedMovieFavoriteMovie.fromJson(json['favorite_movie']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (favorite_movie != null) { - json['favorite_movie'] = - - favorite_movie!.toJson() - -; - } - - - return json; - } - - GetIfFavoritedMovieData({ - - this.favorite_movie, - - }); -} - - - - class GetIfFavoritedMovieVariables { - - String movieId; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - GetIfFavoritedMovieVariables.fromJson(Map json): - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - GetIfFavoritedMovieVariables({ - - required this.movieId, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/get_movie_by_id.dart b/dataconnect/dataconnect/lib/movies_connector/get_movie_by_id.dart deleted file mode 100644 index 56cc681c..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/get_movie_by_id.dart +++ /dev/null @@ -1,912 +0,0 @@ -part of movies_connector; - -class GetMovieByIdVariablesBuilder { - String id; - - - FirebaseDataConnect _dataConnect; - - GetMovieByIdVariablesBuilder(this._dataConnect, {required String this.id,}); - Deserializer dataDeserializer = (dynamic json) => GetMovieByIdData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (GetMovieByIdVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - GetMovieByIdVariables vars=GetMovieByIdVariables(id: id,); - - return _dataConnect.query("GetMovieById", dataDeserializer, varsSerializer, vars); - } -} - - - class GetMovieByIdMovie { - - String id; - - - String title; - - - String imageUrl; - - - int? releaseYear; - - - String? genre; - - - double? rating; - - - String? description; - - - List? tags; - - - List metadata; - - - List mainActors; - - - List supportingActors; - - - List reviews; - - - - - - - GetMovieByIdMovie.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - , - - releaseYear = json['releaseYear'] == null ? null : - - nativeFromJson(json['releaseYear']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - description = json['description'] == null ? null : - - nativeFromJson(json['description']) - - - - , - - tags = json['tags'] == null ? null : - - - (json['tags'] as List) - .map((e) => nativeFromJson(e)) - .toList() - - - - - , - - metadata = - - - (json['metadata'] as List) - .map((e) => GetMovieByIdMovieMetadata.fromJson(e)) - .toList() - - - - - , - - mainActors = - - - (json['mainActors'] as List) - .map((e) => GetMovieByIdMovieMainActors.fromJson(e)) - .toList() - - - - - , - - supportingActors = - - - (json['supportingActors'] as List) - .map((e) => GetMovieByIdMovieSupportingActors.fromJson(e)) - .toList() - - - - - , - - reviews = - - - (json['reviews'] as List) - .map((e) => GetMovieByIdMovieReviews.fromJson(e)) - .toList() - - - - - - { - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - - if (releaseYear != null) { - json['releaseYear'] = - - nativeToJson(releaseYear) - -; - } - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - if (description != null) { - json['description'] = - - nativeToJson(description) - -; - } - - - - if (tags != null) { - json['tags'] = - - - tags?.map((e) => nativeToJson(e)).toList() - - -; - } - - - - json['metadata'] = - - - metadata.map((e) => e.toJson()).toList() - - -; - - - - json['mainActors'] = - - - mainActors.map((e) => e.toJson()).toList() - - -; - - - - json['supportingActors'] = - - - supportingActors.map((e) => e.toJson()).toList() - - -; - - - - json['reviews'] = - - - reviews.map((e) => e.toJson()).toList() - - -; - - - return json; - } - - GetMovieByIdMovie({ - - required this.id, - - required this.title, - - required this.imageUrl, - - this.releaseYear, - - this.genre, - - this.rating, - - this.description, - - this.tags, - - required this.metadata, - - required this.mainActors, - - required this.supportingActors, - - required this.reviews, - - }); -} - - - - class GetMovieByIdMovieMetadata { - - String? director; - - - - - - - GetMovieByIdMovieMetadata.fromJson(dynamic json): - director = json['director'] == null ? null : - - nativeFromJson(json['director']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (director != null) { - json['director'] = - - nativeToJson(director) - -; - } - - - return json; - } - - GetMovieByIdMovieMetadata({ - - this.director, - - }); -} - - - - class GetMovieByIdMovieMainActors { - - String id; - - - String name; - - - String imageUrl; - - - - - - - GetMovieByIdMovieMainActors.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - name = - - nativeFromJson(json['name']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['name'] = - - nativeToJson(name) - -; - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - GetMovieByIdMovieMainActors({ - - required this.id, - - required this.name, - - required this.imageUrl, - - }); -} - - - - class GetMovieByIdMovieSupportingActors { - - String id; - - - String name; - - - String imageUrl; - - - - - - - GetMovieByIdMovieSupportingActors.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - name = - - nativeFromJson(json['name']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['name'] = - - nativeToJson(name) - -; - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - GetMovieByIdMovieSupportingActors({ - - required this.id, - - required this.name, - - required this.imageUrl, - - }); -} - - - - class GetMovieByIdMovieReviews { - - String id; - - - String? reviewText; - - - DateTime reviewDate; - - - int? rating; - - - GetMovieByIdMovieReviewsUser user; - - - - - - - GetMovieByIdMovieReviews.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - reviewText = json['reviewText'] == null ? null : - - nativeFromJson(json['reviewText']) - - - - , - - reviewDate = - - nativeFromJson(json['reviewDate']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - user = - - GetMovieByIdMovieReviewsUser.fromJson(json['user']) - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - if (reviewText != null) { - json['reviewText'] = - - nativeToJson(reviewText) - -; - } - - - - json['reviewDate'] = - - nativeToJson(reviewDate) - -; - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - json['user'] = - - user.toJson() - -; - - - return json; - } - - GetMovieByIdMovieReviews({ - - required this.id, - - this.reviewText, - - required this.reviewDate, - - this.rating, - - required this.user, - - }); -} - - - - class GetMovieByIdMovieReviewsUser { - - String id; - - - String username; - - - - - - - GetMovieByIdMovieReviewsUser.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - username = - - nativeFromJson(json['username']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['username'] = - - nativeToJson(username) - -; - - - return json; - } - - GetMovieByIdMovieReviewsUser({ - - required this.id, - - required this.username, - - }); -} - - - - class GetMovieByIdData { - - GetMovieByIdMovie? movie; - - - - - - - GetMovieByIdData.fromJson(dynamic json): - movie = json['movie'] == null ? null : - - GetMovieByIdMovie.fromJson(json['movie']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (movie != null) { - json['movie'] = - - movie!.toJson() - -; - } - - - return json; - } - - GetMovieByIdData({ - - this.movie, - - }); -} - - - - class GetMovieByIdVariables { - - String id; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - GetMovieByIdVariables.fromJson(Map json): - id = - - nativeFromJson(json['id']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - return json; - } - - GetMovieByIdVariables({ - - required this.id, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/list_movies.dart b/dataconnect/dataconnect/lib/movies_connector/list_movies.dart deleted file mode 100644 index 57399267..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/list_movies.dart +++ /dev/null @@ -1,403 +0,0 @@ -part of movies_connector; - -class ListMoviesVariablesBuilder { - Optional _orderByRating = Optional.optional(orderDirectionDeserializer, enumSerializer); -Optional _orderByReleaseYear = Optional.optional(orderDirectionDeserializer, enumSerializer); -Optional _limit = Optional.optional(nativeFromJson, nativeToJson); - - - FirebaseDataConnect _dataConnect; - ListMoviesVariablesBuilder orderByRating(OrderDirection? t) { -this._orderByRating.value = t; -return this; -} -ListMoviesVariablesBuilder orderByReleaseYear(OrderDirection? t) { -this._orderByReleaseYear.value = t; -return this; -} -ListMoviesVariablesBuilder limit(int? t) { -this._limit.value = t; -return this; -} - - ListMoviesVariablesBuilder(this._dataConnect, ); - Deserializer dataDeserializer = (dynamic json) => ListMoviesData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (ListMoviesVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - ListMoviesVariables vars=ListMoviesVariables(orderByRating: _orderByRating,orderByReleaseYear: _orderByReleaseYear,limit: _limit,); - - return _dataConnect.query("ListMovies", dataDeserializer, varsSerializer, vars); - } -} - - - class ListMoviesMovies { - - String id; - - - String title; - - - String imageUrl; - - - int? releaseYear; - - - String? genre; - - - double? rating; - - - List? tags; - - - String? description; - - - - - - - ListMoviesMovies.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - , - - releaseYear = json['releaseYear'] == null ? null : - - nativeFromJson(json['releaseYear']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - tags = json['tags'] == null ? null : - - - (json['tags'] as List) - .map((e) => nativeFromJson(e)) - .toList() - - - - - , - - description = json['description'] == null ? null : - - nativeFromJson(json['description']) - - - - - { - - - - - - - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - - if (releaseYear != null) { - json['releaseYear'] = - - nativeToJson(releaseYear) - -; - } - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - if (tags != null) { - json['tags'] = - - - tags?.map((e) => nativeToJson(e)).toList() - - -; - } - - - - if (description != null) { - json['description'] = - - nativeToJson(description) - -; - } - - - return json; - } - - ListMoviesMovies({ - - required this.id, - - required this.title, - - required this.imageUrl, - - this.releaseYear, - - this.genre, - - this.rating, - - this.tags, - - this.description, - - }); -} - - - - class ListMoviesData { - - List movies; - - - - - - - ListMoviesData.fromJson(dynamic json): - movies = - - - (json['movies'] as List) - .map((e) => ListMoviesMovies.fromJson(e)) - .toList() - - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movies'] = - - - movies.map((e) => e.toJson()).toList() - - -; - - - return json; - } - - ListMoviesData({ - - required this.movies, - - }); -} - - - - class ListMoviesVariables { - - late OptionalorderByRating; - - - late OptionalorderByReleaseYear; - - - late Optionallimit; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - ListMoviesVariables.fromJson(Map json) { - - - orderByRating = Optional.optional(orderDirectionDeserializer, enumSerializer); - orderByRating.value = json['orderByRating'] == null ? null : - - OrderDirection.values.byName(json['orderByRating']) - -; - - - - orderByReleaseYear = Optional.optional(orderDirectionDeserializer, enumSerializer); - orderByReleaseYear.value = json['orderByReleaseYear'] == null ? null : - - OrderDirection.values.byName(json['orderByReleaseYear']) - -; - - - - limit = Optional.optional(nativeFromJson, nativeToJson); - limit.value = json['limit'] == null ? null : - - nativeFromJson(json['limit']) - -; - - - } - - - Map toJson() { - Map json = {}; - - - if(orderByRating.state == OptionalState.set) { - json['orderByRating'] = orderByRating.toJson(); - } - - - - if(orderByReleaseYear.state == OptionalState.set) { - json['orderByReleaseYear'] = orderByReleaseYear.toJson(); - } - - - - if(limit.state == OptionalState.set) { - json['limit'] = limit.toJson(); - } - - - return json; - } - - ListMoviesVariables({ - - required this.orderByRating, - - required this.orderByReleaseYear, - - required this.limit, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/movies.dart b/dataconnect/dataconnect/lib/movies_connector/movies.dart deleted file mode 100644 index 2ab02827..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/movies.dart +++ /dev/null @@ -1,136 +0,0 @@ -library movies_connector; -import 'package:firebase_data_connect/firebase_data_connect.dart'; -import 'dart:convert'; - -part 'upsert_user.dart'; - -part 'add_favorited_movie.dart'; - -part 'delete_favorited_movie.dart'; - -part 'add_review.dart'; - -part 'update_review.dart'; - -part 'delete_review.dart'; - -part 'list_movies.dart'; - -part 'list_genres.dart'; - -part 'get_movie_by_id.dart'; - -part 'get_actor_by_id.dart'; - -part 'get_current_user.dart'; - -part 'get_if_favorited_movie.dart'; - -part 'search_all.dart'; - - - - enum OrderDirection { - - ASC, - - DESC, - - } - OrderDirection orderDirectionDeserializer(dynamic data) { - return OrderDirection.values.byName(data); - } - - - -String enumSerializer(Enum e) { - return e.name; -} - - - -class MoviesConnector { - - - UpsertUserVariablesBuilder upsertUser ({required String username,}) { - return UpsertUserVariablesBuilder(dataConnect, username: username,); - } - - - AddFavoritedMovieVariablesBuilder addFavoritedMovie ({required String movieId,}) { - return AddFavoritedMovieVariablesBuilder(dataConnect, movieId: movieId,); - } - - - DeleteFavoritedMovieVariablesBuilder deleteFavoritedMovie ({required String movieId,}) { - return DeleteFavoritedMovieVariablesBuilder(dataConnect, movieId: movieId,); - } - - - AddReviewVariablesBuilder addReview ({required String movieId,required int rating,required String reviewText,}) { - return AddReviewVariablesBuilder(dataConnect, movieId: movieId,rating: rating,reviewText: reviewText,); - } - - - UpdateReviewVariablesBuilder updateReview ({required String movieId,required int rating,required String reviewText,}) { - return UpdateReviewVariablesBuilder(dataConnect, movieId: movieId,rating: rating,reviewText: reviewText,); - } - - - DeleteReviewVariablesBuilder deleteReview ({required String movieId,}) { - return DeleteReviewVariablesBuilder(dataConnect, movieId: movieId,); - } - - - ListMoviesVariablesBuilder listMovies () { - return ListMoviesVariablesBuilder(dataConnect, ); - } - - - ListGenresVariablesBuilder listGenres () { - return ListGenresVariablesBuilder(dataConnect, ); - } - - - GetMovieByIdVariablesBuilder getMovieById ({required String id,}) { - return GetMovieByIdVariablesBuilder(dataConnect, id: id,); - } - - - GetActorByIdVariablesBuilder getActorById ({required String id,}) { - return GetActorByIdVariablesBuilder(dataConnect, id: id,); - } - - - GetCurrentUserVariablesBuilder getCurrentUser () { - return GetCurrentUserVariablesBuilder(dataConnect, ); - } - - - GetIfFavoritedMovieVariablesBuilder getIfFavoritedMovie ({required String movieId,}) { - return GetIfFavoritedMovieVariablesBuilder(dataConnect, movieId: movieId,); - } - - - SearchAllVariablesBuilder searchAll ({required int minYear,required int maxYear,required double minRating,required double maxRating,required String genre,}) { - return SearchAllVariablesBuilder(dataConnect, minYear: minYear,maxYear: maxYear,minRating: minRating,maxRating: maxRating,genre: genre,); - } - - - static ConnectorConfig connectorConfig = ConnectorConfig( - 'us-central1', - 'movies', - 'dataconnect', - ); - - MoviesConnector({required this.dataConnect}); - static MoviesConnector get instance { - return MoviesConnector( - dataConnect: FirebaseDataConnect.instanceFor( - connectorConfig: connectorConfig, - sdkType: CallerSDKType.generated)); - } - - FirebaseDataConnect dataConnect; -} - diff --git a/dataconnect/dataconnect/lib/movies_connector/search_all.dart b/dataconnect/dataconnect/lib/movies_connector/search_all.dart deleted file mode 100644 index 27803d0a..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/search_all.dart +++ /dev/null @@ -1,1021 +0,0 @@ -part of movies_connector; - -class SearchAllVariablesBuilder { - Optional _input = Optional.optional(nativeFromJson, nativeToJson); -int minYear; -int maxYear; -double minRating; -double maxRating; -String genre; - - - FirebaseDataConnect _dataConnect; - SearchAllVariablesBuilder input(String? t) { -this._input.value = t; -return this; -} - - SearchAllVariablesBuilder(this._dataConnect, {required int this.minYear,required int this.maxYear,required double this.minRating,required double this.maxRating,required String this.genre,}); - Deserializer dataDeserializer = (dynamic json) => SearchAllData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (SearchAllVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - SearchAllVariables vars=SearchAllVariables(input: _input,minYear: minYear,maxYear: maxYear,minRating: minRating,maxRating: maxRating,genre: genre,); - - return _dataConnect.query("SearchAll", dataDeserializer, varsSerializer, vars); - } -} - - - class SearchAllMoviesMatchingTitle { - - String id; - - - String title; - - - String? genre; - - - double? rating; - - - String imageUrl; - - - - - - - SearchAllMoviesMatchingTitle.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - SearchAllMoviesMatchingTitle({ - - required this.id, - - required this.title, - - this.genre, - - this.rating, - - required this.imageUrl, - - }); -} - - - - class SearchAllMoviesMatchingDescription { - - String id; - - - String title; - - - String? genre; - - - double? rating; - - - String imageUrl; - - - - - - - SearchAllMoviesMatchingDescription.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - , - - genre = json['genre'] == null ? null : - - nativeFromJson(json['genre']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - - if (genre != null) { - json['genre'] = - - nativeToJson(genre) - -; - } - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - SearchAllMoviesMatchingDescription({ - - required this.id, - - required this.title, - - this.genre, - - this.rating, - - required this.imageUrl, - - }); -} - - - - class SearchAllActorsMatchingName { - - String id; - - - String name; - - - String imageUrl; - - - - - - - SearchAllActorsMatchingName.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - name = - - nativeFromJson(json['name']) - - - - , - - imageUrl = - - nativeFromJson(json['imageUrl']) - - - - - { - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['name'] = - - nativeToJson(name) - -; - - - - json['imageUrl'] = - - nativeToJson(imageUrl) - -; - - - return json; - } - - SearchAllActorsMatchingName({ - - required this.id, - - required this.name, - - required this.imageUrl, - - }); -} - - - - class SearchAllReviewsMatchingText { - - String id; - - - int? rating; - - - String? reviewText; - - - DateTime reviewDate; - - - SearchAllReviewsMatchingTextMovie movie; - - - SearchAllReviewsMatchingTextUser user; - - - - - - - SearchAllReviewsMatchingText.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - rating = json['rating'] == null ? null : - - nativeFromJson(json['rating']) - - - - , - - reviewText = json['reviewText'] == null ? null : - - nativeFromJson(json['reviewText']) - - - - , - - reviewDate = - - nativeFromJson(json['reviewDate']) - - - - , - - movie = - - SearchAllReviewsMatchingTextMovie.fromJson(json['movie']) - - - - , - - user = - - SearchAllReviewsMatchingTextUser.fromJson(json['user']) - - - - - { - - - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - if (rating != null) { - json['rating'] = - - nativeToJson(rating) - -; - } - - - - if (reviewText != null) { - json['reviewText'] = - - nativeToJson(reviewText) - -; - } - - - - json['reviewDate'] = - - nativeToJson(reviewDate) - -; - - - - json['movie'] = - - movie.toJson() - -; - - - - json['user'] = - - user.toJson() - -; - - - return json; - } - - SearchAllReviewsMatchingText({ - - required this.id, - - this.rating, - - this.reviewText, - - required this.reviewDate, - - required this.movie, - - required this.user, - - }); -} - - - - class SearchAllReviewsMatchingTextMovie { - - String id; - - - String title; - - - - - - - SearchAllReviewsMatchingTextMovie.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - title = - - nativeFromJson(json['title']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['title'] = - - nativeToJson(title) - -; - - - return json; - } - - SearchAllReviewsMatchingTextMovie({ - - required this.id, - - required this.title, - - }); -} - - - - class SearchAllReviewsMatchingTextUser { - - String id; - - - String username; - - - - - - - SearchAllReviewsMatchingTextUser.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - , - - username = - - nativeFromJson(json['username']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - - json['username'] = - - nativeToJson(username) - -; - - - return json; - } - - SearchAllReviewsMatchingTextUser({ - - required this.id, - - required this.username, - - }); -} - - - - class SearchAllData { - - List moviesMatchingTitle; - - - List moviesMatchingDescription; - - - List actorsMatchingName; - - - List reviewsMatchingText; - - - - - - - SearchAllData.fromJson(dynamic json): - moviesMatchingTitle = - - - (json['moviesMatchingTitle'] as List) - .map((e) => SearchAllMoviesMatchingTitle.fromJson(e)) - .toList() - - - - - , - - moviesMatchingDescription = - - - (json['moviesMatchingDescription'] as List) - .map((e) => SearchAllMoviesMatchingDescription.fromJson(e)) - .toList() - - - - - , - - actorsMatchingName = - - - (json['actorsMatchingName'] as List) - .map((e) => SearchAllActorsMatchingName.fromJson(e)) - .toList() - - - - - , - - reviewsMatchingText = - - - (json['reviewsMatchingText'] as List) - .map((e) => SearchAllReviewsMatchingText.fromJson(e)) - .toList() - - - - - - { - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['moviesMatchingTitle'] = - - - moviesMatchingTitle.map((e) => e.toJson()).toList() - - -; - - - - json['moviesMatchingDescription'] = - - - moviesMatchingDescription.map((e) => e.toJson()).toList() - - -; - - - - json['actorsMatchingName'] = - - - actorsMatchingName.map((e) => e.toJson()).toList() - - -; - - - - json['reviewsMatchingText'] = - - - reviewsMatchingText.map((e) => e.toJson()).toList() - - -; - - - return json; - } - - SearchAllData({ - - required this.moviesMatchingTitle, - - required this.moviesMatchingDescription, - - required this.actorsMatchingName, - - required this.reviewsMatchingText, - - }); -} - - - - class SearchAllVariables { - - late Optionalinput; - - - int minYear; - - - int maxYear; - - - double minRating; - - - double maxRating; - - - String genre; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - SearchAllVariables.fromJson(Map json): - minYear = - - nativeFromJson(json['minYear']) - - - - , - - maxYear = - - nativeFromJson(json['maxYear']) - - - - , - - minRating = - - nativeFromJson(json['minRating']) - - - - , - - maxRating = - - nativeFromJson(json['maxRating']) - - - - , - - genre = - - nativeFromJson(json['genre']) - - - - - { - - - input = Optional.optional(nativeFromJson, nativeToJson); - input.value = json['input'] == null ? null : - - nativeFromJson(json['input']) - -; - - - - - - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - if(input.state == OptionalState.set) { - json['input'] = input.toJson(); - } - - - - json['minYear'] = - - nativeToJson(minYear) - -; - - - - json['maxYear'] = - - nativeToJson(maxYear) - -; - - - - json['minRating'] = - - nativeToJson(minRating) - -; - - - - json['maxRating'] = - - nativeToJson(maxRating) - -; - - - - json['genre'] = - - nativeToJson(genre) - -; - - - return json; - } - - SearchAllVariables({ - - required this.input, - - required this.minYear, - - required this.maxYear, - - required this.minRating, - - required this.maxRating, - - required this.genre, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/update_review.dart b/dataconnect/dataconnect/lib/movies_connector/update_review.dart deleted file mode 100644 index bbd614a2..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/update_review.dart +++ /dev/null @@ -1,242 +0,0 @@ -part of movies_connector; - -class UpdateReviewVariablesBuilder { - String movieId; -int rating; -String reviewText; - - - FirebaseDataConnect _dataConnect; - - UpdateReviewVariablesBuilder(this._dataConnect, {required String this.movieId,required int this.rating,required String this.reviewText,}); - Deserializer dataDeserializer = (dynamic json) => UpdateReviewData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (UpdateReviewVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - MutationRef ref() { - UpdateReviewVariables vars=UpdateReviewVariables(movieId: movieId,rating: rating,reviewText: reviewText,); - - return _dataConnect.mutation("UpdateReview", dataDeserializer, varsSerializer, vars); - } -} - - - class UpdateReviewReviewUpdate { - - String userId; - - - String movieId; - - - - - - - UpdateReviewReviewUpdate.fromJson(dynamic json): - userId = - - nativeFromJson(json['userId']) - - - - , - - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['userId'] = - - nativeToJson(userId) - -; - - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - UpdateReviewReviewUpdate({ - - required this.userId, - - required this.movieId, - - }); -} - - - - class UpdateReviewData { - - UpdateReviewReviewUpdate? review_update; - - - - - - - UpdateReviewData.fromJson(dynamic json): - review_update = json['review_update'] == null ? null : - - UpdateReviewReviewUpdate.fromJson(json['review_update']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (review_update != null) { - json['review_update'] = - - review_update!.toJson() - -; - } - - - return json; - } - - UpdateReviewData({ - - this.review_update, - - }); -} - - - - class UpdateReviewVariables { - - String movieId; - - - int rating; - - - String reviewText; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - UpdateReviewVariables.fromJson(Map json): - movieId = - - nativeFromJson(json['movieId']) - - - - , - - rating = - - nativeFromJson(json['rating']) - - - - , - - reviewText = - - nativeFromJson(json['reviewText']) - - - - - { - - - - - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - - json['rating'] = - - nativeToJson(rating) - -; - - - - json['reviewText'] = - - nativeToJson(reviewText) - -; - - - return json; - } - - UpdateReviewVariables({ - - required this.movieId, - - required this.rating, - - required this.reviewText, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/lib/movies_connector/upsert_user.dart b/dataconnect/dataconnect/lib/movies_connector/upsert_user.dart deleted file mode 100644 index 16d90738..00000000 --- a/dataconnect/dataconnect/lib/movies_connector/upsert_user.dart +++ /dev/null @@ -1,169 +0,0 @@ -part of movies_connector; - -class UpsertUserVariablesBuilder { - String username; - - - FirebaseDataConnect _dataConnect; - - UpsertUserVariablesBuilder(this._dataConnect, {required String this.username,}); - Deserializer dataDeserializer = (dynamic json) => UpsertUserData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (UpsertUserVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - MutationRef ref() { - UpsertUserVariables vars=UpsertUserVariables(username: username,); - - return _dataConnect.mutation("UpsertUser", dataDeserializer, varsSerializer, vars); - } -} - - - class UpsertUserUserUpsert { - - String id; - - - - - - - UpsertUserUserUpsert.fromJson(dynamic json): - id = - - nativeFromJson(json['id']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['id'] = - - nativeToJson(id) - -; - - - return json; - } - - UpsertUserUserUpsert({ - - required this.id, - - }); -} - - - - class UpsertUserData { - - UpsertUserUserUpsert user_upsert; - - - - - - - UpsertUserData.fromJson(dynamic json): - user_upsert = - - UpsertUserUserUpsert.fromJson(json['user_upsert']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['user_upsert'] = - - user_upsert.toJson() - -; - - - return json; - } - - UpsertUserData({ - - required this.user_upsert, - - }); -} - - - - class UpsertUserVariables { - - String username; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - UpsertUserVariables.fromJson(Map json): - username = - - nativeFromJson(json['username']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['username'] = - - nativeToJson(username) - -; - - - return json; - } - - UpsertUserVariables({ - - required this.username, - - }); -} - - - - - - - diff --git a/dataconnect/dataconnect/moviedata_insert.gql b/dataconnect/dataconnect/moviedata_insert.gql index 2f205012..e5b65795 100644 --- a/dataconnect/dataconnect/moviedata_insert.gql +++ b/dataconnect/dataconnect/moviedata_insert.gql @@ -597,9 +597,9 @@ movieActor_insertMany( ) user_insertMany( data: [ - { id: "SnLgOC3lN4hcIl69s53cW0Q8R1T2", username: "sherlock_h" } - { id: "fep4fXpGWsaRpuphq9CIrBIXQ0S2", username: "hercule_p" } - { id: "TBedjwCX0Jf955Uuoxk6k74sY0l1", username: "jane_d" } + { id: "SnLgOC3lN4hcIl69s53cW0Q8R1T2", username: "sherlock_h", name: "Sherlock Holmes" } + { id: "fep4fXpGWsaRpuphq9CIrBIXQ0S2", username: "hercule_p", name: "Hercule Poirot" } + { id: "TBedjwCX0Jf955Uuoxk6k74sY0l1", username: "jane_d", name: "Jane Doe" } ] ) diff --git a/dataconnect/dataconnect/schema/schema.gql b/dataconnect/dataconnect/schema/schema.gql index 721b9a77..444ccfbb 100644 --- a/dataconnect/dataconnect/schema/schema.gql +++ b/dataconnect/dataconnect/schema/schema.gql @@ -46,6 +46,7 @@ type User @table { id: String! @col(name: "user_auth") username: String! @col(name: "username", dataType: "varchar(50)") + name: String! # The following are generated from the @ref in the Review table # reviews_on_user # movies_via_Review @@ -92,4 +93,16 @@ type FavoriteMovie # @ref is implicit user: User! movie: Movie! +} +type FavoriteActor + @table(name: "FavoriteActors", singular: "favorite_actor", plural: "favorite_actors", key: ["user", "actor"]) { + # @ref is implicit + user: User! + actor: Actor! +} +type WatchedMovie + @table(name: "WatchedMovies", singular: "watched_movie", plural: "watched_movies", key: ["user", "movie"]) { + # @ref is implicit + user: User! + movie: Movie! } \ No newline at end of file diff --git a/dataconnect/lib/extensions.dart b/dataconnect/lib/extensions.dart new file mode 100644 index 00000000..490ea227 --- /dev/null +++ b/dataconnect/lib/extensions.dart @@ -0,0 +1,49 @@ +import 'movies_connector/movies.dart'; + +extension GetCurrentUserUserFavoriteMoviesMovieExtension + on GetCurrentUserUserFavoriteMoviesMovie { + ListMoviesMovies get toListMoviesMovies => ListMoviesMovies( + id: id, + title: title, + imageUrl: imageUrl, + description: description, + genre: genre, + rating: rating, + releaseYear: releaseYear, + tags: tags); +} + +extension GetCurrentUserUserWatchedMoviesMovieExtension + on GetCurrentUserUserWatchedMoviesMovie { + ListMoviesMovies get toListMoviesMovies => ListMoviesMovies( + id: id, + title: title, + imageUrl: imageUrl, + description: description, + genre: genre, + rating: rating, + releaseYear: releaseYear, + tags: tags); +} + +extension SearchAllMoviesMatchingTitleExtension + on SearchAllMoviesMatchingTitle { + ListMoviesMovies get toListMoviesMovies => ListMoviesMovies( + id: id, + title: title, + imageUrl: imageUrl, + genre: genre, + rating: rating, + ); +} + +extension SearchAllMoviesMatchingDescriptionExtension + on SearchAllMoviesMatchingDescription { + ListMoviesMovies get toListMoviesMovies => ListMoviesMovies( + id: id, + title: title, + imageUrl: imageUrl, + genre: genre, + rating: rating, + ); +} diff --git a/dataconnect/lib/login.dart b/dataconnect/lib/login.dart index 3817a85a..97f6b3ba 100644 --- a/dataconnect/lib/login.dart +++ b/dataconnect/lib/login.dart @@ -1,3 +1,4 @@ +import 'package:dataconnect/movies_connector/movies.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -35,6 +36,8 @@ class _LoginState extends State { ), const SizedBox(height: 30), TextFormField( + obscureText: true, + autocorrect: false, decoration: const InputDecoration( hintText: "Password", border: OutlineInputBorder()), onChanged: (value) { diff --git a/dataconnect/lib/movie_detail.dart b/dataconnect/lib/movie_detail.dart index 90810f29..8034f80d 100644 --- a/dataconnect/lib/movie_detail.dart +++ b/dataconnect/lib/movie_detail.dart @@ -1,4 +1,5 @@ import 'package:dataconnect/movies_connector/movies.dart'; +import 'package:dataconnect/widgets/login_guard.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; @@ -14,20 +15,41 @@ class MovieDetail extends StatefulWidget { class _MovieDetailState extends State { double _ratingValue = 0; + String _reviewText = ""; bool loading = true; GetMovieByIdData? data; + bool _watched = false; + bool _favorited = false; + + TextEditingController _reviewTextController = TextEditingController(); @override void initState() { super.initState(); MoviesConnector.instance .getMovieById(id: widget.id) - .execute() - .then((value) { + .ref() + .subscribe() + .listen((value) { setState(() { loading = false; data = value.data; }); }); + MoviesConnector.instance + .getMovieInfoForUser(movieId: widget.id) + .ref() + .subscribe() + .listen((value) { + setState(() { + _watched = value.data.watched_movie != null; + _favorited = value.data.favorite_movie != null; + }); + }); + } + + void _refreshData() { + MoviesConnector.instance.getMovieById(id: widget.id).execute(); + MoviesConnector.instance.getMovieInfoForUser(movieId: widget.id).execute(); } List _buildMainDescription() { @@ -79,21 +101,45 @@ class _MovieDetailState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - // TODO(mtewani): Check if the movie has been watched by the user - OutlinedButton.icon( + LoginGuard( + widgetToGuard: OutlinedButton.icon( onPressed: () { - // TODO(mtewani): Check if user is logged in. + (_watched + ? MoviesConnector.instance + .deleteFavoritedMovie(movieId: widget.id) + .execute() + : MoviesConnector.instance + .addFavoritedMovie(movieId: widget.id) + .execute()) + .then( + (value) => setState(() { + _watched = !_watched; + }), + ); }, - icon: const Icon(Icons.check_circle), + icon: Icon( + _watched ? Icons.check_circle : Icons.check_circle_outline), label: const Text('Watched'), - ), - OutlinedButton.icon( + )), + LoginGuard( + widgetToGuard: OutlinedButton.icon( onPressed: () { - // TODO(mtewani): Check if user is logged in. + (_favorited + ? MoviesConnector.instance + .deleteFavoritedMovie(movieId: widget.id) + .execute() + : MoviesConnector.instance + .addFavoritedMovie(movieId: widget.id) + .execute()) + .then((value) { + setState(() { + _favorited = !_favorited; + }); + }); }, - icon: const Icon(Icons.favorite), + icon: Icon(_favorited ? Icons.favorite : Icons.favorite_border), label: const Text('Add To Favorites'), - ) + )) ], ) ]; @@ -184,8 +230,8 @@ class _MovieDetailState extends State { Text("Rating: $_ratingValue"), Slider( value: _ratingValue, - max: 5, - divisions: 10, + max: 10, + divisions: 20, label: _ratingValue.toString(), onChanged: (double value) { setState(() { @@ -193,18 +239,33 @@ class _MovieDetailState extends State { }); }, ), - const TextField( - decoration: InputDecoration( - hintText: "Write your review", - border: OutlineInputBorder(), + LoginGuard( + widgetToGuard: TextField( + decoration: const InputDecoration( + hintText: "Write your review", + border: OutlineInputBorder(), + ), + controller: _reviewTextController, + ), + message: "writing a review"), + LoginGuard( + widgetToGuard: OutlinedButton.icon( + onPressed: () { + // TODO(mtewani): Check if user is logged in. + MoviesConnector.instance + .addReview( + movieId: widget.id, + rating: _ratingValue.toInt(), + reviewText: _reviewTextController.text) + .execute() + .then((_) { + _refreshData(); + _reviewTextController.clear(); + }); + }, + label: const Text('Submit Review'), ), ), - OutlinedButton.icon( - onPressed: () { - // TODO(mtewani): Check if user is logged in. - }, - label: const Text('Submit Review'), - ), ...data!.movie!.reviews.map((review) { return Card( child: Padding( diff --git a/dataconnect/lib/movies_connector/add_review.dart b/dataconnect/lib/movies_connector/add_review.dart index 1205433f..bbf6f7af 100644 --- a/dataconnect/lib/movies_connector/add_review.dart +++ b/dataconnect/lib/movies_connector/add_review.dart @@ -22,7 +22,7 @@ String reviewText; } - class AddReviewReviewInsert { + class AddReviewReviewUpsert { String userId; @@ -34,7 +34,7 @@ String reviewText; - AddReviewReviewInsert.fromJson(dynamic json): + AddReviewReviewUpsert.fromJson(dynamic json): userId = nativeFromJson(json['userId']) @@ -81,7 +81,7 @@ String reviewText; return json; } - AddReviewReviewInsert({ + AddReviewReviewUpsert({ required this.userId, @@ -94,7 +94,7 @@ String reviewText; class AddReviewData { - AddReviewReviewInsert review_insert; + AddReviewReviewUpsert review_upsert; @@ -102,9 +102,9 @@ String reviewText; AddReviewData.fromJson(dynamic json): - review_insert = + review_upsert = - AddReviewReviewInsert.fromJson(json['review_insert']) + AddReviewReviewUpsert.fromJson(json['review_upsert']) @@ -120,9 +120,9 @@ String reviewText; Map json = {}; - json['review_insert'] = + json['review_upsert'] = - review_insert.toJson() + review_upsert.toJson() ; @@ -132,7 +132,7 @@ String reviewText; AddReviewData({ - required this.review_insert, + required this.review_upsert, }); } diff --git a/dataconnect/lib/movies_connector/delete_favorited_actor.dart b/dataconnect/lib/movies_connector/delete_favorited_actor.dart new file mode 100644 index 00000000..ca0d48a8 --- /dev/null +++ b/dataconnect/lib/movies_connector/delete_favorited_actor.dart @@ -0,0 +1,194 @@ +part of movies_connector; + +class DeleteFavoritedActorVariablesBuilder { + String actorId; + + + FirebaseDataConnect _dataConnect; + + DeleteFavoritedActorVariablesBuilder(this._dataConnect, {required String this.actorId,}); + Deserializer dataDeserializer = (dynamic json) => DeleteFavoritedActorData.fromJson(jsonDecode(json)); + Serializer varsSerializer = (DeleteFavoritedActorVariables vars) => jsonEncode(vars.toJson()); + Future> execute() { + return this.ref().execute(); + } + MutationRef ref() { + DeleteFavoritedActorVariables vars=DeleteFavoritedActorVariables(actorId: actorId,); + + return _dataConnect.mutation("DeleteFavoritedActor", dataDeserializer, varsSerializer, vars); + } +} + + + class DeleteFavoritedActorFavoriteActorDelete { + + String userId; + + + String actorId; + + + + + + + DeleteFavoritedActorFavoriteActorDelete.fromJson(dynamic json): + userId = + + nativeFromJson(json['userId']) + + + + , + + actorId = + + nativeFromJson(json['actorId']) + + + + + { + + + + + + } + + + Map toJson() { + Map json = {}; + + + json['userId'] = + + nativeToJson(userId) + +; + + + + json['actorId'] = + + nativeToJson(actorId) + +; + + + return json; + } + + DeleteFavoritedActorFavoriteActorDelete({ + + required this.userId, + + required this.actorId, + + }); +} + + + + class DeleteFavoritedActorData { + + DeleteFavoritedActorFavoriteActorDelete? favorite_actor_delete; + + + + + + + DeleteFavoritedActorData.fromJson(dynamic json): + favorite_actor_delete = json['favorite_actor_delete'] == null ? null : + + DeleteFavoritedActorFavoriteActorDelete.fromJson(json['favorite_actor_delete']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + if (favorite_actor_delete != null) { + json['favorite_actor_delete'] = + + favorite_actor_delete!.toJson() + +; + } + + + return json; + } + + DeleteFavoritedActorData({ + + this.favorite_actor_delete, + + }); +} + + + + class DeleteFavoritedActorVariables { + + String actorId; + + + + + + @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') + + + DeleteFavoritedActorVariables.fromJson(Map json): + actorId = + + nativeFromJson(json['actorId']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['actorId'] = + + nativeToJson(actorId) + +; + + + return json; + } + + DeleteFavoritedActorVariables({ + + required this.actorId, + + }); +} + + + + + + + diff --git a/dataconnect/dataconnect/lib/movies_connector/delete_review.dart b/dataconnect/lib/movies_connector/delete_watched_movie.dart similarity index 50% rename from dataconnect/dataconnect/lib/movies_connector/delete_review.dart rename to dataconnect/lib/movies_connector/delete_watched_movie.dart index 49fe10cd..6c9ae830 100644 --- a/dataconnect/dataconnect/lib/movies_connector/delete_review.dart +++ b/dataconnect/lib/movies_connector/delete_watched_movie.dart @@ -1,26 +1,26 @@ part of movies_connector; -class DeleteReviewVariablesBuilder { +class DeleteWatchedMovieVariablesBuilder { String movieId; FirebaseDataConnect _dataConnect; - DeleteReviewVariablesBuilder(this._dataConnect, {required String this.movieId,}); - Deserializer dataDeserializer = (dynamic json) => DeleteReviewData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (DeleteReviewVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { + DeleteWatchedMovieVariablesBuilder(this._dataConnect, {required String this.movieId,}); + Deserializer dataDeserializer = (dynamic json) => DeleteWatchedMovieData.fromJson(jsonDecode(json)); + Serializer varsSerializer = (DeleteWatchedMovieVariables vars) => jsonEncode(vars.toJson()); + Future> execute() { return this.ref().execute(); } - MutationRef ref() { - DeleteReviewVariables vars=DeleteReviewVariables(movieId: movieId,); + MutationRef ref() { + DeleteWatchedMovieVariables vars=DeleteWatchedMovieVariables(movieId: movieId,); - return _dataConnect.mutation("DeleteReview", dataDeserializer, varsSerializer, vars); + return _dataConnect.mutation("DeleteWatchedMovie", dataDeserializer, varsSerializer, vars); } } - class DeleteReviewReviewDelete { + class DeleteWatchedMovieWatchedMovieDelete { String userId; @@ -32,7 +32,7 @@ class DeleteReviewVariablesBuilder { - DeleteReviewReviewDelete.fromJson(dynamic json): + DeleteWatchedMovieWatchedMovieDelete.fromJson(dynamic json): userId = nativeFromJson(json['userId']) @@ -79,7 +79,7 @@ class DeleteReviewVariablesBuilder { return json; } - DeleteReviewReviewDelete({ + DeleteWatchedMovieWatchedMovieDelete({ required this.userId, @@ -90,19 +90,19 @@ class DeleteReviewVariablesBuilder { - class DeleteReviewData { + class DeleteWatchedMovieData { - DeleteReviewReviewDelete? review_delete; + DeleteWatchedMovieWatchedMovieDelete? watched_movie_delete; - DeleteReviewData.fromJson(dynamic json): - review_delete = json['review_delete'] == null ? null : + DeleteWatchedMovieData.fromJson(dynamic json): + watched_movie_delete = json['watched_movie_delete'] == null ? null : - DeleteReviewReviewDelete.fromJson(json['review_delete']) + DeleteWatchedMovieWatchedMovieDelete.fromJson(json['watched_movie_delete']) @@ -118,10 +118,10 @@ class DeleteReviewVariablesBuilder { Map json = {}; - if (review_delete != null) { - json['review_delete'] = + if (watched_movie_delete != null) { + json['watched_movie_delete'] = - review_delete!.toJson() + watched_movie_delete!.toJson() ; } @@ -130,16 +130,16 @@ class DeleteReviewVariablesBuilder { return json; } - DeleteReviewData({ + DeleteWatchedMovieData({ - this.review_delete, + this.watched_movie_delete, }); } - class DeleteReviewVariables { + class DeleteWatchedMovieVariables { String movieId; @@ -150,7 +150,7 @@ class DeleteReviewVariablesBuilder { @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - DeleteReviewVariables.fromJson(Map json): + DeleteWatchedMovieVariables.fromJson(Map json): movieId = nativeFromJson(json['movieId']) @@ -179,7 +179,7 @@ class DeleteReviewVariablesBuilder { return json; } - DeleteReviewVariables({ + DeleteWatchedMovieVariables({ required this.movieId, diff --git a/dataconnect/lib/movies_connector/get_current_user.dart b/dataconnect/lib/movies_connector/get_current_user.dart index 38a7e191..d319c1f0 100644 --- a/dataconnect/lib/movies_connector/get_current_user.dart +++ b/dataconnect/lib/movies_connector/get_current_user.dart @@ -26,12 +26,21 @@ class GetCurrentUserVariablesBuilder { String username; + String name; + + List reviews; List favoriteMovies; + List favoriteActors; + + + List watchedMovies; + + @@ -51,6 +60,14 @@ class GetCurrentUserVariablesBuilder { + , + + name = + + nativeFromJson(json['name']) + + + , reviews = @@ -75,6 +92,30 @@ class GetCurrentUserVariablesBuilder { + , + + favoriteActors = + + + (json['favoriteActors'] as List) + .map((e) => GetCurrentUserUserFavoriteActors.fromJson(e)) + .toList() + + + + + , + + watchedMovies = + + + (json['watchedMovies'] as List) + .map((e) => GetCurrentUserUserWatchedMovies.fromJson(e)) + .toList() + + + + { @@ -86,6 +127,12 @@ class GetCurrentUserVariablesBuilder { + + + + + + } @@ -109,6 +156,14 @@ class GetCurrentUserVariablesBuilder { + json['name'] = + + nativeToJson(name) + +; + + + json['reviews'] = @@ -125,6 +180,26 @@ class GetCurrentUserVariablesBuilder { favoriteMovies.map((e) => e.toJson()).toList() +; + + + + json['favoriteActors'] = + + + favoriteActors.map((e) => e.toJson()).toList() + + +; + + + + json['watchedMovies'] = + + + watchedMovies.map((e) => e.toJson()).toList() + + ; @@ -137,10 +212,16 @@ class GetCurrentUserVariablesBuilder { required this.username, + required this.name, + required this.reviews, required this.favoriteMovies, + required this.favoriteActors, + + required this.watchedMovies, + }); } @@ -708,6 +789,495 @@ class GetCurrentUserVariablesBuilder { + class GetCurrentUserUserFavoriteActors { + + GetCurrentUserUserFavoriteActorsActor actor; + + + + + + + GetCurrentUserUserFavoriteActors.fromJson(dynamic json): + actor = + + GetCurrentUserUserFavoriteActorsActor.fromJson(json['actor']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['actor'] = + + actor.toJson() + +; + + + return json; + } + + GetCurrentUserUserFavoriteActors({ + + required this.actor, + + }); +} + + + + class GetCurrentUserUserFavoriteActorsActor { + + String id; + + + String name; + + + String imageUrl; + + + + + + + GetCurrentUserUserFavoriteActorsActor.fromJson(dynamic json): + id = + + nativeFromJson(json['id']) + + + + , + + name = + + nativeFromJson(json['name']) + + + + , + + imageUrl = + + nativeFromJson(json['imageUrl']) + + + + + { + + + + + + + + } + + + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + + json['name'] = + + nativeToJson(name) + +; + + + + json['imageUrl'] = + + nativeToJson(imageUrl) + +; + + + return json; + } + + GetCurrentUserUserFavoriteActorsActor({ + + required this.id, + + required this.name, + + required this.imageUrl, + + }); +} + + + + class GetCurrentUserUserWatchedMovies { + + GetCurrentUserUserWatchedMoviesMovie movie; + + + + + + + GetCurrentUserUserWatchedMovies.fromJson(dynamic json): + movie = + + GetCurrentUserUserWatchedMoviesMovie.fromJson(json['movie']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['movie'] = + + movie.toJson() + +; + + + return json; + } + + GetCurrentUserUserWatchedMovies({ + + required this.movie, + + }); +} + + + + class GetCurrentUserUserWatchedMoviesMovie { + + String id; + + + String title; + + + String? genre; + + + String imageUrl; + + + int? releaseYear; + + + double? rating; + + + String? description; + + + List? tags; + + + List metadata; + + + + + + + GetCurrentUserUserWatchedMoviesMovie.fromJson(dynamic json): + id = + + nativeFromJson(json['id']) + + + + , + + title = + + nativeFromJson(json['title']) + + + + , + + genre = json['genre'] == null ? null : + + nativeFromJson(json['genre']) + + + + , + + imageUrl = + + nativeFromJson(json['imageUrl']) + + + + , + + releaseYear = json['releaseYear'] == null ? null : + + nativeFromJson(json['releaseYear']) + + + + , + + rating = json['rating'] == null ? null : + + nativeFromJson(json['rating']) + + + + , + + description = json['description'] == null ? null : + + nativeFromJson(json['description']) + + + + , + + tags = json['tags'] == null ? null : + + + (json['tags'] as List) + .map((e) => nativeFromJson(e)) + .toList() + + + + + , + + metadata = + + + (json['metadata'] as List) + .map((e) => GetCurrentUserUserWatchedMoviesMovieMetadata.fromJson(e)) + .toList() + + + + + + { + + + + + + + + + + + + + + + + + + + + } + + + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + + json['title'] = + + nativeToJson(title) + +; + + + + if (genre != null) { + json['genre'] = + + nativeToJson(genre) + +; + } + + + + json['imageUrl'] = + + nativeToJson(imageUrl) + +; + + + + if (releaseYear != null) { + json['releaseYear'] = + + nativeToJson(releaseYear) + +; + } + + + + if (rating != null) { + json['rating'] = + + nativeToJson(rating) + +; + } + + + + if (description != null) { + json['description'] = + + nativeToJson(description) + +; + } + + + + if (tags != null) { + json['tags'] = + + + tags?.map((e) => nativeToJson(e)).toList() + + +; + } + + + + json['metadata'] = + + + metadata.map((e) => e.toJson()).toList() + + +; + + + return json; + } + + GetCurrentUserUserWatchedMoviesMovie({ + + required this.id, + + required this.title, + + this.genre, + + required this.imageUrl, + + this.releaseYear, + + this.rating, + + this.description, + + this.tags, + + required this.metadata, + + }); +} + + + + class GetCurrentUserUserWatchedMoviesMovieMetadata { + + String? director; + + + + + + + GetCurrentUserUserWatchedMoviesMovieMetadata.fromJson(dynamic json): + director = json['director'] == null ? null : + + nativeFromJson(json['director']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + if (director != null) { + json['director'] = + + nativeToJson(director) + +; + } + + + return json; + } + + GetCurrentUserUserWatchedMoviesMovieMetadata({ + + this.director, + + }); +} + + + class GetCurrentUserData { GetCurrentUserUser? user; diff --git a/dataconnect/lib/movies_connector/get_if_favorited_movie.dart b/dataconnect/lib/movies_connector/get_if_favorited_movie.dart deleted file mode 100644 index 901fb84e..00000000 --- a/dataconnect/lib/movies_connector/get_if_favorited_movie.dart +++ /dev/null @@ -1,171 +0,0 @@ -part of movies_connector; - -class GetIfFavoritedMovieVariablesBuilder { - String movieId; - - - FirebaseDataConnect _dataConnect; - - GetIfFavoritedMovieVariablesBuilder(this._dataConnect, {required String this.movieId,}); - Deserializer dataDeserializer = (dynamic json) => GetIfFavoritedMovieData.fromJson(jsonDecode(json)); - Serializer varsSerializer = (GetIfFavoritedMovieVariables vars) => jsonEncode(vars.toJson()); - Future> execute() { - return this.ref().execute(); - } - QueryRef ref() { - GetIfFavoritedMovieVariables vars=GetIfFavoritedMovieVariables(movieId: movieId,); - - return _dataConnect.query("GetIfFavoritedMovie", dataDeserializer, varsSerializer, vars); - } -} - - - class GetIfFavoritedMovieFavoriteMovie { - - String movieId; - - - - - - - GetIfFavoritedMovieFavoriteMovie.fromJson(dynamic json): - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - GetIfFavoritedMovieFavoriteMovie({ - - required this.movieId, - - }); -} - - - - class GetIfFavoritedMovieData { - - GetIfFavoritedMovieFavoriteMovie? favorite_movie; - - - - - - - GetIfFavoritedMovieData.fromJson(dynamic json): - favorite_movie = json['favorite_movie'] == null ? null : - - GetIfFavoritedMovieFavoriteMovie.fromJson(json['favorite_movie']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - if (favorite_movie != null) { - json['favorite_movie'] = - - favorite_movie!.toJson() - -; - } - - - return json; - } - - GetIfFavoritedMovieData({ - - this.favorite_movie, - - }); -} - - - - class GetIfFavoritedMovieVariables { - - String movieId; - - - - - - @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') - - - GetIfFavoritedMovieVariables.fromJson(Map json): - movieId = - - nativeFromJson(json['movieId']) - - - - - { - - - - } - - - Map toJson() { - Map json = {}; - - - json['movieId'] = - - nativeToJson(movieId) - -; - - - return json; - } - - GetIfFavoritedMovieVariables({ - - required this.movieId, - - }); -} - - - - - - - diff --git a/dataconnect/lib/movies_connector/get_movie_info_for_user.dart b/dataconnect/lib/movies_connector/get_movie_info_for_user.dart new file mode 100644 index 00000000..272e49ea --- /dev/null +++ b/dataconnect/lib/movies_connector/get_movie_info_for_user.dart @@ -0,0 +1,243 @@ +part of movies_connector; + +class GetMovieInfoForUserVariablesBuilder { + String movieId; + + + FirebaseDataConnect _dataConnect; + + GetMovieInfoForUserVariablesBuilder(this._dataConnect, {required String this.movieId,}); + Deserializer dataDeserializer = (dynamic json) => GetMovieInfoForUserData.fromJson(jsonDecode(json)); + Serializer varsSerializer = (GetMovieInfoForUserVariables vars) => jsonEncode(vars.toJson()); + Future> execute() { + return this.ref().execute(); + } + QueryRef ref() { + GetMovieInfoForUserVariables vars=GetMovieInfoForUserVariables(movieId: movieId,); + + return _dataConnect.query("GetMovieInfoForUser", dataDeserializer, varsSerializer, vars); + } +} + + + class GetMovieInfoForUserFavoriteMovie { + + String movieId; + + + + + + + GetMovieInfoForUserFavoriteMovie.fromJson(dynamic json): + movieId = + + nativeFromJson(json['movieId']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['movieId'] = + + nativeToJson(movieId) + +; + + + return json; + } + + GetMovieInfoForUserFavoriteMovie({ + + required this.movieId, + + }); +} + + + + class GetMovieInfoForUserWatchedMovie { + + String movieId; + + + + + + + GetMovieInfoForUserWatchedMovie.fromJson(dynamic json): + movieId = + + nativeFromJson(json['movieId']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['movieId'] = + + nativeToJson(movieId) + +; + + + return json; + } + + GetMovieInfoForUserWatchedMovie({ + + required this.movieId, + + }); +} + + + + class GetMovieInfoForUserData { + + GetMovieInfoForUserFavoriteMovie? favorite_movie; + + + GetMovieInfoForUserWatchedMovie? watched_movie; + + + + + + + GetMovieInfoForUserData.fromJson(dynamic json): + favorite_movie = json['favorite_movie'] == null ? null : + + GetMovieInfoForUserFavoriteMovie.fromJson(json['favorite_movie']) + + + + , + + watched_movie = json['watched_movie'] == null ? null : + + GetMovieInfoForUserWatchedMovie.fromJson(json['watched_movie']) + + + + + { + + + + + + } + + + Map toJson() { + Map json = {}; + + + if (favorite_movie != null) { + json['favorite_movie'] = + + favorite_movie!.toJson() + +; + } + + + + if (watched_movie != null) { + json['watched_movie'] = + + watched_movie!.toJson() + +; + } + + + return json; + } + + GetMovieInfoForUserData({ + + this.favorite_movie, + + this.watched_movie, + + }); +} + + + + class GetMovieInfoForUserVariables { + + String movieId; + + + + + + @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') + + + GetMovieInfoForUserVariables.fromJson(Map json): + movieId = + + nativeFromJson(json['movieId']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['movieId'] = + + nativeToJson(movieId) + +; + + + return json; + } + + GetMovieInfoForUserVariables({ + + required this.movieId, + + }); +} + + + + + + + diff --git a/dataconnect/lib/movies_connector/list_movies_by_partial_title.dart b/dataconnect/lib/movies_connector/list_movies_by_partial_title.dart new file mode 100644 index 00000000..f9e40abc --- /dev/null +++ b/dataconnect/lib/movies_connector/list_movies_by_partial_title.dart @@ -0,0 +1,271 @@ +part of movies_connector; + +class ListMoviesByPartialTitleVariablesBuilder { + String input; + + + FirebaseDataConnect _dataConnect; + + ListMoviesByPartialTitleVariablesBuilder(this._dataConnect, {required String this.input,}); + Deserializer dataDeserializer = (dynamic json) => ListMoviesByPartialTitleData.fromJson(jsonDecode(json)); + Serializer varsSerializer = (ListMoviesByPartialTitleVariables vars) => jsonEncode(vars.toJson()); + Future> execute() { + return this.ref().execute(); + } + QueryRef ref() { + ListMoviesByPartialTitleVariables vars=ListMoviesByPartialTitleVariables(input: input,); + + return _dataConnect.query("ListMoviesByPartialTitle", dataDeserializer, varsSerializer, vars); + } +} + + + class ListMoviesByPartialTitleMovies { + + String id; + + + String title; + + + String? genre; + + + double? rating; + + + String imageUrl; + + + + + + + ListMoviesByPartialTitleMovies.fromJson(dynamic json): + id = + + nativeFromJson(json['id']) + + + + , + + title = + + nativeFromJson(json['title']) + + + + , + + genre = json['genre'] == null ? null : + + nativeFromJson(json['genre']) + + + + , + + rating = json['rating'] == null ? null : + + nativeFromJson(json['rating']) + + + + , + + imageUrl = + + nativeFromJson(json['imageUrl']) + + + + + { + + + + + + + + + + + + } + + + Map toJson() { + Map json = {}; + + + json['id'] = + + nativeToJson(id) + +; + + + + json['title'] = + + nativeToJson(title) + +; + + + + if (genre != null) { + json['genre'] = + + nativeToJson(genre) + +; + } + + + + if (rating != null) { + json['rating'] = + + nativeToJson(rating) + +; + } + + + + json['imageUrl'] = + + nativeToJson(imageUrl) + +; + + + return json; + } + + ListMoviesByPartialTitleMovies({ + + required this.id, + + required this.title, + + this.genre, + + this.rating, + + required this.imageUrl, + + }); +} + + + + class ListMoviesByPartialTitleData { + + List movies; + + + + + + + ListMoviesByPartialTitleData.fromJson(dynamic json): + movies = + + + (json['movies'] as List) + .map((e) => ListMoviesByPartialTitleMovies.fromJson(e)) + .toList() + + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['movies'] = + + + movies.map((e) => e.toJson()).toList() + + +; + + + return json; + } + + ListMoviesByPartialTitleData({ + + required this.movies, + + }); +} + + + + class ListMoviesByPartialTitleVariables { + + String input; + + + + + + @Deprecated('fromJson is deprecated for Variable classes as they are no longer required for deserialization.') + + + ListMoviesByPartialTitleVariables.fromJson(Map json): + input = + + nativeFromJson(json['input']) + + + + + { + + + + } + + + Map toJson() { + Map json = {}; + + + json['input'] = + + nativeToJson(input) + +; + + + return json; + } + + ListMoviesByPartialTitleVariables({ + + required this.input, + + }); +} + + + + + + + diff --git a/dataconnect/lib/movies_connector/movies.dart b/dataconnect/lib/movies_connector/movies.dart index cf9114d7..d0bbd1ea 100644 --- a/dataconnect/lib/movies_connector/movies.dart +++ b/dataconnect/lib/movies_connector/movies.dart @@ -8,6 +8,10 @@ part 'add_favorited_movie.dart'; part 'delete_favorited_movie.dart'; +part 'delete_favorited_actor.dart'; + +part 'delete_watched_movie.dart'; + part 'add_review.dart'; part 'update_review.dart'; @@ -26,10 +30,12 @@ part 'get_actor_by_id.dart'; part 'get_current_user.dart'; -part 'get_if_favorited_movie.dart'; +part 'get_movie_info_for_user.dart'; part 'search_all.dart'; +part 'list_movies_by_partial_title.dart'; + enum OrderDirection { @@ -54,8 +60,8 @@ String enumSerializer(Enum e) { class MoviesConnector { - UpsertUserVariablesBuilder upsertUser ({required String username,}) { - return UpsertUserVariablesBuilder(dataConnect, username: username,); + UpsertUserVariablesBuilder upsertUser ({required String username,required String name,}) { + return UpsertUserVariablesBuilder(dataConnect, username: username,name: name,); } @@ -69,6 +75,16 @@ class MoviesConnector { } + DeleteFavoritedActorVariablesBuilder deleteFavoritedActor ({required String actorId,}) { + return DeleteFavoritedActorVariablesBuilder(dataConnect, actorId: actorId,); + } + + + DeleteWatchedMovieVariablesBuilder deleteWatchedMovie ({required String movieId,}) { + return DeleteWatchedMovieVariablesBuilder(dataConnect, movieId: movieId,); + } + + AddReviewVariablesBuilder addReview ({required String movieId,required int rating,required String reviewText,}) { return AddReviewVariablesBuilder(dataConnect, movieId: movieId,rating: rating,reviewText: reviewText,); } @@ -114,8 +130,8 @@ class MoviesConnector { } - GetIfFavoritedMovieVariablesBuilder getIfFavoritedMovie ({required String movieId,}) { - return GetIfFavoritedMovieVariablesBuilder(dataConnect, movieId: movieId,); + GetMovieInfoForUserVariablesBuilder getMovieInfoForUser ({required String movieId,}) { + return GetMovieInfoForUserVariablesBuilder(dataConnect, movieId: movieId,); } @@ -123,6 +139,11 @@ class MoviesConnector { return SearchAllVariablesBuilder(dataConnect, minYear: minYear,maxYear: maxYear,minRating: minRating,maxRating: maxRating,genre: genre,); } + + ListMoviesByPartialTitleVariablesBuilder listMoviesByPartialTitle ({required String input,}) { + return ListMoviesByPartialTitleVariablesBuilder(dataConnect, input: input,); + } + static ConnectorConfig connectorConfig = ConnectorConfig( 'us-central1', diff --git a/dataconnect/lib/movies_connector/upsert_user.dart b/dataconnect/lib/movies_connector/upsert_user.dart index 16d90738..6e472735 100644 --- a/dataconnect/lib/movies_connector/upsert_user.dart +++ b/dataconnect/lib/movies_connector/upsert_user.dart @@ -2,18 +2,19 @@ part of movies_connector; class UpsertUserVariablesBuilder { String username; +String name; FirebaseDataConnect _dataConnect; - UpsertUserVariablesBuilder(this._dataConnect, {required String this.username,}); + UpsertUserVariablesBuilder(this._dataConnect, {required String this.username,required String this.name,}); Deserializer dataDeserializer = (dynamic json) => UpsertUserData.fromJson(jsonDecode(json)); Serializer varsSerializer = (UpsertUserVariables vars) => jsonEncode(vars.toJson()); Future> execute() { return this.ref().execute(); } MutationRef ref() { - UpsertUserVariables vars=UpsertUserVariables(username: username,); + UpsertUserVariables vars=UpsertUserVariables(username: username,name: name,); return _dataConnect.mutation("UpsertUser", dataDeserializer, varsSerializer, vars); } @@ -119,6 +120,9 @@ class UpsertUserVariablesBuilder { String username; + String name; + + @@ -132,11 +136,21 @@ class UpsertUserVariablesBuilder { + , + + name = + + nativeFromJson(json['name']) + + + { + + } @@ -151,6 +165,14 @@ class UpsertUserVariablesBuilder { ; + + json['name'] = + + nativeToJson(name) + +; + + return json; } @@ -158,6 +180,8 @@ class UpsertUserVariablesBuilder { required this.username, + required this.name, + }); } diff --git a/dataconnect/lib/profile.dart b/dataconnect/lib/profile.dart index 1a7768ff..14364f78 100644 --- a/dataconnect/lib/profile.dart +++ b/dataconnect/lib/profile.dart @@ -1,5 +1,8 @@ +import 'package:dataconnect/extensions.dart'; import 'package:dataconnect/main.dart'; +import 'package:dataconnect/movies_connector/movies.dart'; import 'package:dataconnect/util/auth.dart'; +import 'package:dataconnect/widgets/list_movies.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -13,6 +16,10 @@ class Profile extends StatefulWidget { class _ProfileState extends State { User? _currentUser; + List _favoriteMovies = []; + List _favoriteActors = []; + List _watchedMovies = []; + String? _displayName; @override void initState() { super.initState(); @@ -21,6 +28,16 @@ class _ProfileState extends State { _currentUser = user; }); }); + MoviesConnector.instance.getCurrentUser().execute().then((res) { + setState(() { + _displayName = res.data.user!.name; + _favoriteMovies = + res.data.user!.favoriteMovies.map((e) => e.movie).toList(); + _favoriteActors = res.data.user!.favoriteActors; + _watchedMovies = + res.data.user!.watchedMovies.map((e) => e.movie).toList(); + }); + }); } Widget _UserInfo() { @@ -47,11 +64,30 @@ class _ProfileState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [CircularProgressIndicator()], ) - : Container( + : SingleChildScrollView( + child: Container( padding: EdgeInsets.all(30), child: Column( - children: [_UserInfo()], + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _UserInfo(), + ListMovies( + title: "Watched Movies", + movies: _watchedMovies + .map( + (e) => e.toListMoviesMovies, + ) + .toList()), + ListMovies( + title: "Favorite Movies", + movies: _favoriteMovies + .map( + (e) => e.toListMoviesMovies, + ) + .toList()) + ], ), - ); + )); } } diff --git a/dataconnect/lib/router.dart b/dataconnect/lib/router.dart index f639a8b3..fbe1d0b1 100644 --- a/dataconnect/lib/router.dart +++ b/dataconnect/lib/router.dart @@ -1,6 +1,7 @@ import 'package:dataconnect/destination.dart'; import 'package:dataconnect/login.dart'; import 'package:dataconnect/profile.dart'; +import 'package:dataconnect/search.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -55,7 +56,7 @@ var router = GoRouter(initialLocation: homePath.path, routes: [ StatefulShellBranch(routes: [ GoRoute( path: "/search", - builder: (context, state) => const Text('abc'), + builder: (context, state) => const Search(), ), ]), StatefulShellBranch(routes: [ @@ -68,6 +69,9 @@ var router = GoRouter(initialLocation: homePath.path, routes: [ GoRoute( path: "/login", builder: (context, state) => const Login(), + redirect: (context, state) async { + return (await Auth.isLoggedIn()) ? '/profile' : null; + }, ), GoRoute( path: "/signup", diff --git a/dataconnect/lib/search.dart b/dataconnect/lib/search.dart new file mode 100644 index 00000000..342b771f --- /dev/null +++ b/dataconnect/lib/search.dart @@ -0,0 +1,270 @@ +import 'package:dataconnect/extensions.dart'; +import 'package:dataconnect/movies_connector/movies.dart'; +import 'package:dataconnect/widgets/list_actors.dart'; +import 'package:dataconnect/widgets/list_movies.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +class Search extends StatefulWidget { + const Search({super.key}); + + @override + State createState() => _SearchState(); +} + +class SearchFormState { + String title = ''; + int maxYear = 2024; + int minYear = 1900; + double minRating = 1.0; + double maxRating = 5.0; + String genre = ''; + @override + String toString() { + return { + 'title': title, + 'maxYear': maxYear, + 'minYear': minYear, + 'minRating': minRating, + 'maxRating': maxRating, + 'genre': genre + }.toString(); + } +} + +class _SearchState extends State { + final _formKey = GlobalKey(); + final SearchFormState _searchFormState = SearchFormState(); + List _resultsMovieMatchingTitle = []; + List _resultsMovieMatchingDescription = + []; + List _actorsMatchingName = []; + List _reviewsMatchingText = []; + + void _searchMovie() { + MoviesConnector.instance + .searchAll( + minYear: _searchFormState.minYear, + maxYear: _searchFormState.maxYear, + minRating: _searchFormState.minRating, + maxRating: _searchFormState.maxRating, + genre: _searchFormState.genre, + ) + .input(_searchFormState.title) + .execute() + .then((value) { + setState(() { + _actorsMatchingName = value.data.actorsMatchingName; + _resultsMovieMatchingTitle = value.data.moviesMatchingTitle; + _resultsMovieMatchingDescription = value.data.moviesMatchingDescription; + _reviewsMatchingText = value.data.reviewsMatchingText; + }); + }); + } + + Widget _buildForm() { + return Form( + key: _formKey, + child: Column( + children: [ + Row( + children: [ + Expanded( + flex: 4, + child: TextFormField( + initialValue: _searchFormState.title, + decoration: const InputDecoration(hintText: 'Title'), + onChanged: (value) { + setState(() { + _searchFormState.title = value; + }); + }, + ), + ), + const SizedBox(width: 10), + Expanded( + flex: 1, + child: IconButton( + icon: const Icon(Icons.search), + onPressed: () { + _searchMovie(); + }, + ), + ), + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: TextFormField( + initialValue: _searchFormState.minYear.toString(), + decoration: + const InputDecoration(hintText: 'Release Year From'), + keyboardType: TextInputType.number, + onChanged: (value) { + print(value); + setState(() { + _searchFormState.minYear = int.parse(value); + }); + }, + ), + ), + const SizedBox(width: 10), + Expanded( + flex: 1, + child: TextFormField( + initialValue: _searchFormState.genre, + decoration: const InputDecoration(hintText: 'Genre'), + onChanged: (value) { + setState(() { + _searchFormState.genre = value; + }); + }, + ), + ), + const SizedBox(width: 10), + Expanded( + flex: 1, + child: TextFormField( + initialValue: _searchFormState.minRating.toString(), + decoration: const InputDecoration(hintText: 'Rating From'), + keyboardType: TextInputType.number, + onChanged: (value) { + setState(() { + _searchFormState.minRating = + value.isEmpty ? 0 : double.parse(value); + }); + }, + ), + ) + ], + ), + Row( + children: [ + Expanded( + flex: 1, + child: TextFormField( + initialValue: _searchFormState.maxYear.toString(), + decoration: + const InputDecoration(hintText: 'Release Year To'), + keyboardType: TextInputType.number, + onChanged: (value) { + setState(() { + _searchFormState.maxYear = int.parse(value); + }); + }, + ), + ), + const Expanded( + flex: 1, + child: SizedBox(), + ), + const SizedBox(width: 10), + Expanded( + flex: 1, + child: TextFormField( + initialValue: _searchFormState.maxRating.toString(), + decoration: const InputDecoration(hintText: 'Rating To'), + keyboardType: TextInputType.number, + onChanged: (value) { + setState(() { + _searchFormState.maxRating = + value.isEmpty ? 0 : double.parse(value); + }); + }, + ), + ) + ], + ) + ], + )); + } + + Widget _buildRatingList() { + return SizedBox( + height: 125, + child: Expanded( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + var rating = _reviewsMatchingText[index]; + return Card( + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(rating.user.username), + Row( + children: [ + Text(DateFormat.yMMMd().format(rating.reviewDate)), + const SizedBox( + width: 10, + ), + Text("Rating ${rating.rating}") + ], + ), + Text(rating.reviewText!) + ], + )), + ); + }, + itemCount: _reviewsMatchingText.length, + ))); + + // return Expanded(child: Text('abc')); + } + + Widget _buildResults() { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Results', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30)), + ListMovies( + movies: _resultsMovieMatchingTitle + .map((e) => e.toListMoviesMovies) + .toList(), + title: "Movies Matching Title"), + ListMovies( + movies: _resultsMovieMatchingDescription + .map((e) => e.toListMoviesMovies) + .toList(), + title: "Movies Matching Description"), + const Text('Results matching reviews', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)), + ], + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: SingleChildScrollView( + child: Container( + margin: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('Advanced Search', + style: TextStyle( + fontWeight: FontWeight.bold, fontSize: 30)), + _buildForm(), + _buildResults(), + _buildRatingList(), + ListActors( + title: "Actors Matching Title", + actors: _actorsMatchingName + .map((actor) => Actor( + id: actor.id, + imageUrl: actor.imageUrl, + name: actor.name)) + .toList()) + ], + ))))); + } +} diff --git a/dataconnect/lib/sign_up.dart b/dataconnect/lib/sign_up.dart index 676f1387..fcdcd226 100644 --- a/dataconnect/lib/sign_up.dart +++ b/dataconnect/lib/sign_up.dart @@ -1,3 +1,4 @@ +import 'package:dataconnect/movies_connector/movies.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -13,7 +14,7 @@ class _SignUpState extends State { final _formKey = GlobalKey(); String _username = ''; String _password = ''; - String _confirmPassword = ''; + String _name = ''; Widget _buildForm() { return Form( key: _formKey, @@ -36,22 +37,17 @@ class _SignUpState extends State { ), const SizedBox(height: 30), TextFormField( - obscureText: true, enableSuggestions: false, - autocorrect: false, decoration: const InputDecoration( - hintText: "Password", border: OutlineInputBorder()), + hintText: "Name", border: OutlineInputBorder()), onChanged: (value) { setState(() { - _password = value; + _name = value; }); }, validator: (value) { if (value == null || value.isEmpty) { - return 'Please enter a password'; - } - if (value != _confirmPassword) { - return 'Passwords do not match'; + return 'Please enter a name'; } return null; }, @@ -62,19 +58,16 @@ class _SignUpState extends State { enableSuggestions: false, autocorrect: false, decoration: const InputDecoration( - hintText: "Confirm Password", border: OutlineInputBorder()), + hintText: "Password", border: OutlineInputBorder()), validator: (value) { if (value == null || value.isEmpty) { return 'Please enter some text'; } - if (value != _password) { - return 'Passwords do not match'; - } return null; }, onChanged: (value) { setState(() { - _confirmPassword = value; + _password = value; }); }, ), @@ -95,6 +88,9 @@ class _SignUpState extends State { try { await FirebaseAuth.instance.createUserWithEmailAndPassword( email: _username, password: _password); + await MoviesConnector.instance + .upsertUser(username: _username, name: _name) + .execute(); if (mounted) { context.go('/home'); } diff --git a/dataconnect/lib/util/auth.dart b/dataconnect/lib/util/auth.dart index b31c1409..5935ce58 100644 --- a/dataconnect/lib/util/auth.dart +++ b/dataconnect/lib/util/auth.dart @@ -1,9 +1,18 @@ import 'package:firebase_auth/firebase_auth.dart'; class Auth { - static isLoggedIn() async { + static Future isLoggedIn() async { User? user = await FirebaseAuth.instance.authStateChanges().first; - return user != null; + if (user == null) { + return false; + } + try { + String? idToken = await user.getIdToken(); + print(idToken); + return idToken != null; + } catch (_) { + return false; + } } static getCurrentUser() { diff --git a/dataconnect/lib/widgets/list_actors.dart b/dataconnect/lib/widgets/list_actors.dart new file mode 100644 index 00000000..47ea5dbd --- /dev/null +++ b/dataconnect/lib/widgets/list_actors.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; + +class Actor { + Actor({required this.imageUrl, required this.name, required this.id}); + String imageUrl; + String name; + String id; +} + +class ListActors extends StatefulWidget { + const ListActors({super.key, required this.actors, required this.title}); + final List actors; + final String title; + + @override + State createState() => _ListActorsState(); +} + +class _ListActorsState extends State { + _buildActor(Actor actor) { + return SizedBox( + width: 100, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + CircleAvatar( + radius: 30, + child: ClipOval(child: Image.network(actor.imageUrl))), + Text( + actor.name, + overflow: TextOverflow.ellipsis, + ) + ])); + } + + _buildActorsList() { + return SizedBox( + height: 125, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.title, + style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + Expanded( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + return _buildActor(widget.actors[index]); + }, + itemCount: widget.actors.length, + )) + ], + )); + } + + @override + Widget build(BuildContext context) { + return _buildActorsList(); + } +} diff --git a/dataconnect/lib/widgets/list_movies.dart b/dataconnect/lib/widgets/list_movies.dart new file mode 100644 index 00000000..b9ac39a0 --- /dev/null +++ b/dataconnect/lib/widgets/list_movies.dart @@ -0,0 +1,91 @@ +import 'package:dataconnect/movies_connector/movies.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class ListMovies extends StatefulWidget { + const ListMovies({super.key, required this.movies, required this.title}); + + final List movies; + final String title; + @override + State createState() => _ListMoviesState(); +} + +class _ListMoviesState extends State { + Widget _buildMovieList(String title, List movies) { + return Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + title, + style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + ), + ), + movies.isEmpty + ? Padding( + padding: const EdgeInsets.all(10.0), + child: Text( + "No $title", + style: const TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), + )) + : SizedBox( + height: 300, // Adjust the height as needed + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: movies.length, + itemBuilder: (context, index) { + return _buildMovieItem(movies[index]); + }, + ), + ), + ], + ); + } + + void _visitDetail(String id) { + context.push("/movies/$id"); + } + + Widget _buildMovieItem(ListMoviesMovies movie) { + return Container( + width: 150, // Adjust the width as needed + padding: const EdgeInsets.all(4.0), + child: Card( + child: InkWell( + onTap: () { + _visitDetail(movie.id); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AspectRatio( + aspectRatio: 9 / 16, // 9:16 aspect ratio for the image + child: Image.network( + movie.imageUrl, + fit: BoxFit.cover, + ), + ), + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + movie.title, + overflow: TextOverflow.ellipsis, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + ), + ], + )), + ), + ); + } + + @override + Widget build(BuildContext context) { + return _buildMovieList(widget.title, widget.movies); + } +} diff --git a/dataconnect/lib/widgets/login_guard.dart b/dataconnect/lib/widgets/login_guard.dart new file mode 100644 index 00000000..3072c4c4 --- /dev/null +++ b/dataconnect/lib/widgets/login_guard.dart @@ -0,0 +1,38 @@ +import 'package:dataconnect/util/auth.dart'; +import 'package:flutter/material.dart'; + +class LoginGuard extends StatefulWidget { + const LoginGuard({super.key, required this.widgetToGuard, this.message}); + + final Widget widgetToGuard; + + final String? message; + + @override + State createState() => _LoginGuardState(); +} + +class _LoginGuardState extends State { + bool isLoggedIn = false; + @override + void initState() { + super.initState(); + Auth.isLoggedIn().then((value) { + setState(() { + isLoggedIn = value; + }); + }); + } + + @override + Widget build(BuildContext context) { + if (isLoggedIn) { + return widget.widgetToGuard; + } + if (widget.message == null) { + return const SizedBox(); + } + return Text( + 'Please visit the Profile page to log in before ${widget.message}'); + } +}