Skip to content

Commit bbba5e8

Browse files
deep-diverkkweon
andauthored
feat: construct header section in detail view (#57)
* construct header section in detail view * remove test server code * comment out unimplemented statements * Update client/lib/widgets/detail/header.dart Co-authored-by: Mo Kweon <kkweon@gmail.com> * Update client/lib/screens/detail_screen.dart Co-authored-by: Mo Kweon <kkweon@gmail.com> * Update client/lib/widgets/detail/youtube.dart Co-authored-by: Mo Kweon <kkweon@gmail.com> * part of information injected from Video object. * remove unused imports * update Video proto message * update header to use updated Video proto message Co-authored-by: Mo Kweon <kkweon@gmail.com>
1 parent f5dd85f commit bbba5e8

File tree

13 files changed

+306
-124
lines changed

13 files changed

+306
-124
lines changed

client/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ SPEC CHECKSUMS:
3030

3131
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
3232

33-
COCOAPODS: 1.10.1
33+
COCOAPODS: 1.10.0

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

Lines changed: 28 additions & 0 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: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:pr12er/protos/pkg/pr12er/messages.pb.dart';
3-
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
3+
import 'package:pr12er/widgets/detail/header.dart';
44
import 'package:pr12er/utils/extractor.dart';
5+
import 'package:pr12er/widgets/detail/youtube.dart';
56

67
class DetailScreenArguments {
78
final Video video;
@@ -12,59 +13,51 @@ class DetailScreenArguments {
1213
class DetailScreen extends StatelessWidget {
1314
static const String routeName = "detail_app";
1415

16+
Widget getHorizontalLine() {
17+
return const Divider(
18+
height: 5,
19+
color: Colors.black,
20+
indent: 5,
21+
endIndent: 5,
22+
);
23+
}
24+
1525
@override
1626
Widget build(BuildContext context) {
1727
final args =
1828
// ignore: cast_nullable_to_non_nullable
1929
ModalRoute.of(context)!.settings.arguments as DetailScreenArguments;
2030

2131
return Scaffold(
22-
appBar: AppBar(
23-
leading: IconButton(
24-
icon: const Icon(Icons.arrow_back),
25-
onPressed: () {
26-
Navigator.pop(context);
27-
},
28-
),
29-
title: Text(args.video.title,
30-
key: const ValueKey("$routeName/appBar/title")),
32+
appBar: AppBar(
33+
leading: IconButton(
34+
icon: const Icon(Icons.arrow_back),
35+
onPressed: () {
36+
Navigator.pop(context);
37+
},
3138
),
32-
body: Detail(youtubeId: extractYoutubeId(args.video.link)));
33-
}
34-
}
35-
36-
class Detail extends StatefulWidget {
37-
final String youtubeId;
38-
39-
const Detail({required this.youtubeId});
40-
41-
@override
42-
_DetailState createState() => _DetailState();
43-
}
44-
45-
class _DetailState extends State<Detail> {
46-
late final YoutubePlayerController _controller;
47-
48-
@override
49-
void initState() {
50-
super.initState();
51-
52-
_controller = YoutubePlayerController(
53-
initialVideoId: widget.youtubeId,
54-
);
55-
}
56-
57-
@override
58-
Widget build(BuildContext context) {
59-
return YoutubePlayerBuilder(
60-
player: YoutubePlayer(
61-
controller: _controller,
39+
title: Text(args.video.title,
40+
key: const ValueKey("$routeName/appBar/title")),
41+
),
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+
]))
59+
],
6260
),
63-
builder: (context, player) {
64-
return Column(
65-
children: [player],
66-
);
67-
},
6861
);
6962
}
7063
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AbstractWidget extends StatelessWidget {
4+
const AbstractWidget({Key? key}) : super(key: key);
5+
6+
@override
7+
Widget build(BuildContext context) {
8+
return Container();
9+
}
10+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:pr12er/protos/pkg/pr12er/messages.pb.dart';
3+
4+
// ignore: must_be_immutable
5+
class HeaderWidget extends StatelessWidget {
6+
// this is a placeholder
7+
// didILIkedIt should be replaced in the next future PR
8+
// after defining user related information
9+
bool didILikedIt = false;
10+
11+
late Video video;
12+
13+
HeaderWidget({Key? key, required this.video}) : super(key: key);
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return Container(
18+
margin: const EdgeInsets.only(top: 10),
19+
child: Row(
20+
mainAxisAlignment: MainAxisAlignment.center,
21+
children: [
22+
...getPresenterWidgets(),
23+
const SizedBox(width: 25),
24+
...getViewNumbersWidgets(),
25+
const SizedBox(width: 25),
26+
...getDateWidgets(),
27+
],
28+
),
29+
);
30+
}
31+
32+
Widget getLikeIcon() {
33+
if (didILikedIt) {
34+
return const Icon(Icons.thumb_up_alt);
35+
}
36+
return const Icon(Icons.thumb_up_alt_outlined);
37+
}
38+
39+
List<Widget> getViewNumbersWidgets() {
40+
return [
41+
const SizedBox(width: 8),
42+
const Icon(Icons.remove_red_eye),
43+
const SizedBox(width: 8),
44+
Text(video.numberOfViews.toString(),
45+
style: const TextStyle(fontSize: 18)),
46+
const SizedBox(width: 15),
47+
getLikeIcon(),
48+
const SizedBox(width: 8),
49+
Text(video.numberOfLike.toString(), style: const TextStyle(fontSize: 18)),
50+
];
51+
}
52+
53+
List<Widget> getPresenterWidgets() {
54+
return [
55+
Text(video.presenter,
56+
style: const TextStyle(
57+
color: Colors.black54, fontSize: 18, fontStyle: FontStyle.italic))
58+
];
59+
}
60+
61+
List<Widget> getDateWidgets() {
62+
return [
63+
const Icon(Icons.today),
64+
const SizedBox(width: 8),
65+
Text(video.publishedDate, style: const TextStyle(fontSize: 18))
66+
];
67+
}
68+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:flutter/material.dart';
2+
3+
class RecommentationWidget extends StatelessWidget {
4+
const RecommentationWidget({Key? key}) : super(key: key);
5+
6+
@override
7+
Widget build(BuildContext context) {
8+
return Container();
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:flutter/material.dart';
2+
3+
class RepositoryWidget extends StatelessWidget {
4+
const RepositoryWidget({Key? key}) : super(key: key);
5+
6+
@override
7+
Widget build(BuildContext context) {
8+
return Container();
9+
}
10+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
3+
4+
class YoutubeWidget extends StatefulWidget {
5+
final String youtubeId;
6+
7+
const YoutubeWidget({Key? key, required this.youtubeId}) : super(key: key);
8+
9+
@override
10+
_DetailState createState() => _DetailState();
11+
}
12+
13+
class _DetailState extends State<YoutubeWidget> {
14+
late final YoutubePlayerController _controller;
15+
16+
@override
17+
void initState() {
18+
super.initState();
19+
20+
_controller = YoutubePlayerController(
21+
initialVideoId: widget.youtubeId,
22+
);
23+
}
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
return YoutubePlayerBuilder(
28+
player: YoutubePlayer(
29+
controller: _controller,
30+
),
31+
builder: (context, player) {
32+
return Column(
33+
children: [player],
34+
);
35+
},
36+
);
37+
}
38+
}

0 commit comments

Comments
 (0)