Skip to content

Commit 6a67e52

Browse files
authored
Merge pull request #96 from rodydavis/sample-fix
Fix some of the Flutter logic
2 parents fd4d783 + 813f4a6 commit 6a67e52

21 files changed

+1024
-823
lines changed

dataconnect/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

dataconnect/firebase.json

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

dataconnect/lib/actor_detail.dart

Lines changed: 66 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,78 @@
1-
import 'package:dataconnect/movie_state.dart';
2-
import 'package:dataconnect/movies_connector/movies.dart';
3-
import 'package:dataconnect/widgets/list_movies.dart';
41
import 'package:flutter/material.dart';
52

6-
class ActorDetail extends StatefulWidget {
7-
const ActorDetail({super.key, required this.actorId});
3+
import 'movie_state.dart';
4+
import 'widgets/list_movies.dart';
85

9-
final String actorId;
10-
11-
@override
12-
State<ActorDetail> createState() => _ActorDetailState();
13-
}
14-
15-
class _ActorDetailState extends State<ActorDetail> {
16-
bool loading = true;
17-
GetActorByIdActor? actor;
18-
@override
19-
void initState() {
20-
super.initState();
21-
22-
MovieState.getActorById(widget.actorId).then((value) {
23-
setState(() {
24-
loading = false;
25-
actor = value.data.actor;
26-
});
27-
});
28-
}
6+
class ActorDetail extends StatelessWidget {
7+
const ActorDetail({
8+
super.key,
9+
required this.actorId,
10+
});
2911

30-
_buildActorInfo() {
31-
return [
32-
Align(
33-
alignment: Alignment.centerLeft,
34-
child: Container(
35-
child: Text(
36-
actor!.name,
37-
style: const TextStyle(fontSize: 30),
38-
),
39-
)),
40-
Row(
41-
mainAxisAlignment: MainAxisAlignment.start,
42-
crossAxisAlignment: CrossAxisAlignment.start,
43-
children: [
44-
Expanded(
45-
child: AspectRatio(
46-
aspectRatio: 9 / 16, // 9:16 aspect ratio for the image
47-
child: Image.network(
48-
actor!.imageUrl,
49-
fit: BoxFit.cover,
50-
),
51-
),
52-
),
53-
]),
54-
];
55-
}
56-
57-
Widget _buildMainRoles() {
58-
return ListMovies(
59-
movies: MovieState.convertMainActorDetail(actor!.mainActors),
60-
title: "Main Roles");
61-
}
62-
63-
Widget _buildSupportingRoles() {
64-
return ListMovies(
65-
movies:
66-
MovieState.convertSupportingActorDetail(actor!.supportingActors),
67-
title: "Supporting Roles");
68-
}
12+
final String actorId;
6913

7014
@override
7115
Widget build(BuildContext context) {
72-
return Scaffold(
73-
body: SafeArea(
74-
child: actor == null
75-
? const Column(
76-
mainAxisAlignment: MainAxisAlignment.center,
77-
crossAxisAlignment: CrossAxisAlignment.center,
78-
children: [CircularProgressIndicator()],
79-
)
80-
: Padding(
81-
padding: const EdgeInsets.all(30),
82-
child: SingleChildScrollView(
83-
child: Column(
16+
return FutureBuilder(
17+
future: MovieState.getActorById(actorId),
18+
builder: (context, snapshot) {
19+
final actor = snapshot.data?.data.actor;
20+
final loading = snapshot.connectionState == ConnectionState.waiting;
21+
return Scaffold(
22+
body: SafeArea(
23+
child: () {
24+
if (actor == null || loading) {
25+
return const Center(
26+
child: CircularProgressIndicator(),
27+
);
28+
}
29+
return Padding(
30+
padding: const EdgeInsets.all(30),
31+
child: SingleChildScrollView(
32+
child: Column(
8433
children: [
85-
..._buildActorInfo(),
86-
_buildMainRoles(),
87-
_buildSupportingRoles()
34+
Align(
35+
alignment: Alignment.centerLeft,
36+
child: Text(
37+
actor.name,
38+
style: const TextStyle(fontSize: 30),
39+
)),
40+
Row(
41+
mainAxisAlignment: MainAxisAlignment.start,
42+
crossAxisAlignment: CrossAxisAlignment.start,
43+
children: [
44+
Expanded(
45+
child: AspectRatio(
46+
aspectRatio:
47+
9 / 16, // 9:16 aspect ratio for the image
48+
child: Image.network(
49+
actor.imageUrl,
50+
fit: BoxFit.cover,
51+
),
52+
),
53+
),
54+
],
55+
),
56+
ListMovies(
57+
movies: MovieState.convertMainActorDetail(
58+
actor.mainActors,
59+
),
60+
title: "Main Roles",
61+
),
62+
ListMovies(
63+
movies: MovieState.convertSupportingActorDetail(
64+
actor.supportingActors,
65+
),
66+
title: "Supporting Roles",
67+
),
8868
],
89-
)))),
69+
),
70+
),
71+
);
72+
}(),
73+
),
74+
);
75+
},
9076
);
9177
}
9278
}

dataconnect/lib/destination.dart

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
import 'package:flutter/material.dart';
22

3-
class Destination {
4-
const Destination({required this.label, required this.icon});
5-
final String label;
6-
final IconData icon;
7-
}
8-
9-
class Route {
10-
Route({required this.path, required this.label, required this.iconData});
3+
class Route extends NavigationDestination {
4+
Route({
5+
super.key,
6+
required this.path,
7+
required super.label,
8+
required this.iconData,
9+
}) : super(icon: Icon(iconData));
1110
final String path;
12-
final String label;
1311
final IconData iconData;
1412
}
1513

16-
var homePath = Route(path: '/home', label: 'Home', iconData: Icons.home);
17-
var searchPath =
18-
Route(path: '/search', label: 'Search', iconData: Icons.search);
19-
var profilePath =
20-
Route(path: '/profile', label: 'Profile', iconData: Icons.person);
21-
var paths = [homePath, searchPath, profilePath];
14+
final homePath = Route(
15+
path: '/home',
16+
label: 'Home',
17+
iconData: Icons.home,
18+
);
19+
final searchPath = Route(
20+
path: '/search',
21+
label: 'Search',
22+
iconData: Icons.search,
23+
);
24+
final profilePath = Route(
25+
path: '/profile',
26+
label: 'Profile',
27+
iconData: Icons.person,
28+
);
29+
30+
final paths = [homePath, searchPath, profilePath];

0 commit comments

Comments
 (0)