Skip to content

Commit 4e4e088

Browse files
authored
feat: Abstract widget to detail view (#66)
* add paper argument to detail screen * add FutureBuilder and getDetails for the service * clean up unnecessary widgets * add getKyewords method * update scroll view * add bookmark icon * add floating action button * add bookmark icon * add repository widget * remove sprintf dependency * test number reformatter * remove the training .0 * apply reformatNumbers to the view and like numbers * update proto for Timestamp and title in Paper message * replace placeholder values with the actual proto objects. * update dummy messages for GetDetails * add missing service.dart * resolve warnings by flutter analyze * exclude rule for mock files
1 parent fad61ff commit 4e4e088

25 files changed

+648
-187
lines changed

client/analysis_options.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
include: package:lint/analysis_options.yaml
22
analyzer:
33
exclude:
4-
- lib/**/*.pb*.dart
4+
- lib/**/*.pb*.dart
5+
- lib/test-server.dart
6+
- test/**/*.mocks.dart
78.5 KB
Binary file not shown.
78.2 KB
Binary file not shown.
71.9 KB
Binary file not shown.

client/images/pytorch-logo.png

14.3 KB
Loading

client/images/tf-logo.png

8.91 KB
Loading

client/lib/protos/pkg/pr12er/messages.pb.dart

Lines changed: 38 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/lib/protos/pkg/pr12er/messages.pbjson.dart

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/lib/screens/detail_screen.dart

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import 'package:flutter/material.dart';
22
import 'package:pr12er/protos/pkg/pr12er/messages.pb.dart';
3+
import 'package:pr12er/service.dart';
4+
import 'package:pr12er/widgets/detail/abstract.dart';
35
import 'package:pr12er/widgets/detail/header.dart';
46
import 'package:pr12er/utils/extractor.dart';
7+
import 'package:pr12er/widgets/detail/recommendataion.dart';
8+
import 'package:pr12er/widgets/detail/repository.dart';
59
import 'package:pr12er/widgets/detail/youtube.dart';
10+
import 'package:provider/provider.dart';
611

712
class DetailScreenArguments {
813
final Video video;
@@ -39,25 +44,64 @@ class DetailScreen extends StatelessWidget {
3944
title: Text(args.video.title,
4045
key: const ValueKey("$routeName/appBar/title")),
4146
),
42-
body: CustomScrollView(
43-
slivers: [
44-
SliverList(
45-
delegate: SliverChildListDelegate([
46-
YoutubeWidget(youtubeId: extractYoutubeId(args.video.link)),
47-
Container(
48-
margin: const EdgeInsets.only(top: 5, left: 10, right: 10),
49-
child: Column(
50-
children: [
51-
HeaderWidget(video: args.video),
52-
const SizedBox(height: 10),
53-
getHorizontalLine(),
54-
const SizedBox(height: 10),
55-
],
56-
),
57-
)
58-
]))
47+
body: Column(
48+
children: [
49+
YoutubeWidget(youtubeId: extractYoutubeId(args.video.link)),
50+
Expanded(
51+
child: CustomScrollView(
52+
slivers: [
53+
SliverList(
54+
delegate: SliverChildListDelegate([
55+
Container(
56+
margin: const EdgeInsets.only(top: 5, left: 10, right: 10),
57+
child: Column(
58+
children: [
59+
HeaderWidget(video: args.video),
60+
const SizedBox(height: 10),
61+
getHorizontalLine(),
62+
const SizedBox(height: 10),
63+
FutureBuilder<Detail>(
64+
future: context
65+
.read<GrpcClient>()
66+
.getDetails(args.video.id),
67+
builder: (context, AsyncSnapshot<Detail> snapshot) {
68+
if (!snapshot.hasData) {
69+
return const Center(
70+
child: CircularProgressIndicator());
71+
}
72+
73+
return Column(children: [
74+
PaperAbstractWidget(
75+
paper: snapshot.data!.paper[0]),
76+
const SizedBox(height: 10),
77+
getHorizontalLine(),
78+
const SizedBox(height: 10),
79+
RecommentationWidget(detail: snapshot.data!),
80+
const SizedBox(height: 10),
81+
getHorizontalLine(),
82+
const SizedBox(height: 10),
83+
RepositoryWidget(
84+
repositories:
85+
snapshot.data!.paper[0].repositories,
86+
)
87+
]);
88+
},
89+
)
90+
],
91+
),
92+
)
93+
]))
94+
],
95+
),
96+
),
5997
],
6098
),
99+
floatingActionButton: FloatingActionButton(
100+
onPressed: () {
101+
// Add your onPressed code here!
102+
},
103+
child: const Icon(Icons.email),
104+
),
61105
);
62106
}
63107
}

client/lib/screens/main_screen.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ class MainScreen extends StatelessWidget {
1515
Widget build(BuildContext context) {
1616
return Scaffold(
1717
appBar: AppBar(
18-
leading: const Icon(Icons.search),
18+
actions: <Widget>[
19+
IconButton(
20+
icon: const Icon(Icons.search),
21+
onPressed: () {
22+
// do something
23+
},
24+
)
25+
],
1926
title: const Text(appName),
2027
),
2128
body: PRVideos());

0 commit comments

Comments
 (0)