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

client/fonts/DancingScript-Medium.ttf

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
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,23 @@ class Detail extends $pb.GeneratedMessage {
245245
class Paper extends $pb.GeneratedMessage {
246246
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Paper', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pkg.pr12er'), createEmptyInstance: create)
247247
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'paperId')
248-
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'arxivId')
249-
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'absract')
250-
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pubDate')
251-
..pPS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'authors')
252-
..pc<Repository>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'repositories', $pb.PbFieldType.PM, subBuilder: Repository.create)
253-
..pc<Method>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'methods', $pb.PbFieldType.PM, subBuilder: Method.create)
248+
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'title')
249+
..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'arxivId')
250+
..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'absract')
251+
..aOM<$1.Timestamp>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pubDate', subBuilder: $1.Timestamp.create)
252+
..pPS(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'authors')
253+
..pc<Repository>(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'repositories', $pb.PbFieldType.PM, subBuilder: Repository.create)
254+
..pc<Method>(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'methods', $pb.PbFieldType.PM, subBuilder: Method.create)
254255
..hasRequiredFields = false
255256
;
256257

257258
Paper._() : super();
258259
factory Paper({
259260
$core.String? paperId,
261+
$core.String? title,
260262
$core.String? arxivId,
261263
$core.String? absract,
262-
$core.String? pubDate,
264+
$1.Timestamp? pubDate,
263265
$core.Iterable<$core.String>? authors,
264266
$core.Iterable<Repository>? repositories,
265267
$core.Iterable<Method>? methods,
@@ -268,6 +270,9 @@ class Paper extends $pb.GeneratedMessage {
268270
if (paperId != null) {
269271
_result.paperId = paperId;
270272
}
273+
if (title != null) {
274+
_result.title = title;
275+
}
271276
if (arxivId != null) {
272277
_result.arxivId = arxivId;
273278
}
@@ -319,40 +324,51 @@ class Paper extends $pb.GeneratedMessage {
319324
void clearPaperId() => clearField(1);
320325

321326
@$pb.TagNumber(2)
322-
$core.String get arxivId => $_getSZ(1);
327+
$core.String get title => $_getSZ(1);
323328
@$pb.TagNumber(2)
324-
set arxivId($core.String v) { $_setString(1, v); }
329+
set title($core.String v) { $_setString(1, v); }
325330
@$pb.TagNumber(2)
326-
$core.bool hasArxivId() => $_has(1);
331+
$core.bool hasTitle() => $_has(1);
327332
@$pb.TagNumber(2)
328-
void clearArxivId() => clearField(2);
333+
void clearTitle() => clearField(2);
329334

330335
@$pb.TagNumber(3)
331-
$core.String get absract => $_getSZ(2);
336+
$core.String get arxivId => $_getSZ(2);
332337
@$pb.TagNumber(3)
333-
set absract($core.String v) { $_setString(2, v); }
338+
set arxivId($core.String v) { $_setString(2, v); }
334339
@$pb.TagNumber(3)
335-
$core.bool hasAbsract() => $_has(2);
340+
$core.bool hasArxivId() => $_has(2);
336341
@$pb.TagNumber(3)
337-
void clearAbsract() => clearField(3);
342+
void clearArxivId() => clearField(3);
338343

339344
@$pb.TagNumber(4)
340-
$core.String get pubDate => $_getSZ(3);
345+
$core.String get absract => $_getSZ(3);
341346
@$pb.TagNumber(4)
342-
set pubDate($core.String v) { $_setString(3, v); }
347+
set absract($core.String v) { $_setString(3, v); }
343348
@$pb.TagNumber(4)
344-
$core.bool hasPubDate() => $_has(3);
349+
$core.bool hasAbsract() => $_has(3);
345350
@$pb.TagNumber(4)
346-
void clearPubDate() => clearField(4);
351+
void clearAbsract() => clearField(4);
347352

348353
@$pb.TagNumber(5)
349-
$core.List<$core.String> get authors => $_getList(4);
354+
$1.Timestamp get pubDate => $_getN(4);
355+
@$pb.TagNumber(5)
356+
set pubDate($1.Timestamp v) { setField(5, v); }
357+
@$pb.TagNumber(5)
358+
$core.bool hasPubDate() => $_has(4);
359+
@$pb.TagNumber(5)
360+
void clearPubDate() => clearField(5);
361+
@$pb.TagNumber(5)
362+
$1.Timestamp ensurePubDate() => $_ensure(4);
350363

351364
@$pb.TagNumber(6)
352-
$core.List<Repository> get repositories => $_getList(5);
365+
$core.List<$core.String> get authors => $_getList(5);
353366

354367
@$pb.TagNumber(7)
355-
$core.List<Method> get methods => $_getList(6);
368+
$core.List<Repository> get repositories => $_getList(6);
369+
370+
@$pb.TagNumber(8)
371+
$core.List<Method> get methods => $_getList(7);
356372
}
357373

358374
class Repository extends $pb.GeneratedMessage {

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,18 @@ const Paper$json = const {
7272
'1': 'Paper',
7373
'2': const [
7474
const {'1': 'paper_id', '3': 1, '4': 1, '5': 9, '10': 'paperId'},
75-
const {'1': 'arxiv_id', '3': 2, '4': 1, '5': 9, '10': 'arxivId'},
76-
const {'1': 'absract', '3': 3, '4': 1, '5': 9, '10': 'absract'},
77-
const {'1': 'pub_date', '3': 4, '4': 1, '5': 9, '10': 'pubDate'},
78-
const {'1': 'authors', '3': 5, '4': 3, '5': 9, '10': 'authors'},
79-
const {'1': 'repositories', '3': 6, '4': 3, '5': 11, '6': '.pkg.pr12er.Repository', '10': 'repositories'},
80-
const {'1': 'methods', '3': 7, '4': 3, '5': 11, '6': '.pkg.pr12er.Method', '10': 'methods'},
75+
const {'1': 'title', '3': 2, '4': 1, '5': 9, '10': 'title'},
76+
const {'1': 'arxiv_id', '3': 3, '4': 1, '5': 9, '10': 'arxivId'},
77+
const {'1': 'absract', '3': 4, '4': 1, '5': 9, '10': 'absract'},
78+
const {'1': 'pub_date', '3': 5, '4': 1, '5': 11, '6': '.google.protobuf.Timestamp', '10': 'pubDate'},
79+
const {'1': 'authors', '3': 6, '4': 3, '5': 9, '10': 'authors'},
80+
const {'1': 'repositories', '3': 7, '4': 3, '5': 11, '6': '.pkg.pr12er.Repository', '10': 'repositories'},
81+
const {'1': 'methods', '3': 8, '4': 3, '5': 11, '6': '.pkg.pr12er.Method', '10': 'methods'},
8182
],
8283
};
8384

8485
/// Descriptor for `Paper`. Decode as a `google.protobuf.DescriptorProto`.
85-
final $typed_data.Uint8List paperDescriptor = $convert.base64Decode('CgVQYXBlchIZCghwYXBlcl9pZBgBIAEoCVIHcGFwZXJJZBIZCghhcnhpdl9pZBgCIAEoCVIHYXJ4aXZJZBIYCgdhYnNyYWN0GAMgASgJUgdhYnNyYWN0EhkKCHB1Yl9kYXRlGAQgASgJUgdwdWJEYXRlEhgKB2F1dGhvcnMYBSADKAlSB2F1dGhvcnMSOgoMcmVwb3NpdG9yaWVzGAYgAygLMhYucGtnLnByMTJlci5SZXBvc2l0b3J5UgxyZXBvc2l0b3JpZXMSLAoHbWV0aG9kcxgHIAMoCzISLnBrZy5wcjEyZXIuTWV0aG9kUgdtZXRob2Rz');
86+
final $typed_data.Uint8List paperDescriptor = $convert.base64Decode('CgVQYXBlchIZCghwYXBlcl9pZBgBIAEoCVIHcGFwZXJJZBIUCgV0aXRsZRgCIAEoCVIFdGl0bGUSGQoIYXJ4aXZfaWQYAyABKAlSB2FyeGl2SWQSGAoHYWJzcmFjdBgEIAEoCVIHYWJzcmFjdBI1CghwdWJfZGF0ZRgFIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5UaW1lc3RhbXBSB3B1YkRhdGUSGAoHYXV0aG9ycxgGIAMoCVIHYXV0aG9ycxI6CgxyZXBvc2l0b3JpZXMYByADKAsyFi5wa2cucHIxMmVyLlJlcG9zaXRvcnlSDHJlcG9zaXRvcmllcxIsCgdtZXRob2RzGAggAygLMhIucGtnLnByMTJlci5NZXRob2RSB21ldGhvZHM=');
8687
@$core.Deprecated('Use repositoryDescriptor instead')
8788
const Repository$json = const {
8889
'1': 'Repository',

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)