Skip to content

Commit eadb916

Browse files
Merge pull request #3 from softmarshmallow/beta
Beta
2 parents e5d0abd + 1b53fd8 commit eadb916

14 files changed

+256
-60
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ dependencies:
5757
https://www.pinterest.com/official_softmarshmallow/flutter-timeline/
5858

5959

60-
## simple example
60+
## simple example [(run it now!)](https://softmarshmallow.github.io/flutter-timeline/)
6161
![demo app](./docs/images/mac-ss.png)
6262
![demo app](./docs/images/mac-ss-2.png)
6363
![demo app](./docs/images/mac-ss-3.png)

example/lib/main.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:example/screen/cms_comments_demo.dart';
2+
import 'package:example/screen/github_activity_demo.dart';
23
import 'package:example/screen/plain_timeline_demo.dart';
34
import 'package:flutter/material.dart';
45
import 'package:flutter_timeline/flutter_timeline.dart';
@@ -19,7 +20,8 @@ class TimelineDemoApp extends StatelessWidget {
1920
),
2021
routes: {
2122
PlainTimelineDemoScreen.routeName: (c) => PlainTimelineDemoScreen(),
22-
CmsCommentsDemoScreen.routeName: (c) => CmsCommentsDemoScreen(),
23+
DeskTimelineDemoScreen.routeName: (c) => DeskTimelineDemoScreen(),
24+
GithubActivityDemo.routeName: (c) => GithubActivityDemo(),
2325
},
2426
home: DemoHomePage(title: 'Flutter Timeline Demo'),
2527
);
@@ -33,13 +35,18 @@ List<DemoScreen> demos = [
3335
cover: null,
3436
route: PlainTimelineDemoScreen.routeName),
3537
DemoScreen(
36-
name: "cms / e-commerce with comments",
37-
description: "demo for creating timeline such like shopify",
38+
name: "github activity",
39+
description: "github's activity timeline demo",
3840
cover: null,
39-
route: CmsCommentsDemoScreen.routeName),
41+
route: GithubActivityDemo.routeName),
4042
DemoScreen(
41-
name: "plain timeline",
42-
description: "simplest timeline demo",
43+
name: "genoplan desk",
44+
description: "genoplan's desk crm app timeline demo",
45+
cover: null,
46+
route: DeskTimelineDemoScreen.routeName),
47+
DemoScreen(
48+
name: "shopify",
49+
description: "timeline demo from shopify admin",
4350
cover: null,
4451
route: PlainTimelineDemoScreen.routeName),
4552
];

example/lib/screen/cms_comments_demo.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_timeline/flutter_timeline.dart';
33
import 'package:flutter_timeline/timeline.dart';
44

5-
class CmsCommentsDemoScreen extends StatefulWidget {
5+
class DeskTimelineDemoScreen extends StatefulWidget {
66
static const routeName = "/demo/cms-comments";
77

88
@override
9-
State<StatefulWidget> createState() => _CmsCommentsDemoScreenState();
9+
State<StatefulWidget> createState() => _DeskTimelineDemoScreenState();
1010
}
1111

12-
class _CmsCommentsDemoScreenState extends State<CmsCommentsDemoScreen> {
12+
class _DeskTimelineDemoScreenState extends State<DeskTimelineDemoScreen> {
1313
@override
1414
Widget build(BuildContext context) {
1515
return Scaffold(
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import 'package:example/themes/github_theme.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_timeline/flutter_timeline.dart';
4+
5+
class GithubActivityDemo extends StatefulWidget {
6+
static const routeName = "/demo/github-activity";
7+
8+
@override
9+
State<StatefulWidget> createState() => _GithubActivityDemoState();
10+
}
11+
12+
class _GithubActivityDemoState extends State<GithubActivityDemo> {
13+
@override
14+
Widget build(BuildContext context) {
15+
return Theme(data: makeGithubTheme(), child: buildScreen());
16+
}
17+
18+
Widget buildScreen() {
19+
return Scaffold(
20+
appBar: AppBar(
21+
title: Text("github"),
22+
),
23+
body: buildBody(),
24+
);
25+
}
26+
27+
Widget buildBody() {
28+
return SingleChildScrollView(
29+
child: Column(
30+
children: [buildTimeline()],
31+
),
32+
);
33+
}
34+
35+
Widget buildTimeline() {
36+
return Timeline(events: [TimelineEventDisplay(child: Text("wow"))]);
37+
}
38+
}
39+
40+
/// github's timeline card (the embedded type of card, not event itself)
41+
/// <div class="profile-timeline-card bg-white border border-gray-dark rounded-1 p-3">
42+
/// <svg class="octicon octicon-issue-closed closed d-inline-block mt-1 float-left" title="Closed" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 0110.65-5.003.75.75 0 00.959-1.153 8 8 0 102.592 8.33.75.75 0 10-1.444-.407A6.5 6.5 0 011.5 8zM8 12a1 1 0 100-2 1 1 0 000 2zm0-8a.75.75 0 01.75.75v3.5a.75.75 0 11-1.5 0v-3.5A.75.75 0 018 4zm4.78 4.28l3-3a.75.75 0 00-1.06-1.06l-2.47 2.47-.97-.97a.749.749 0 10-1.06 1.06l1.5 1.5a.75.75 0 001.06 0z"></path></svg>
43+
/// <div class="ml-4">
44+
/// <h3 class="lh-condensed my-0">
45+
/// <a class="text-gray-dark" data-hovercard-type="issue" data-hovercard-url="/nuxt/content/issues/339/hovercard" href="/nuxt/content/issues/339">use content theme on existing nuxt project</a>
46+
/// </h3>
47+
///
48+
/// <div class="text-gray mb-0 mt-2 ">
49+
/// <p><a href="https://github.com/nuxt/content/edit/dev/docs/content/en/themes-docs.md">https://github.com/nuxt/content/edit/dev/docs/content/en/themes-docs.md</a>
50+
///this example is outdated and wont work.
51+
///<span class="pl-k">import</span> <span class="pl-s1">theme</span> <span class="pl-k">from</span> <span class="pl-s">'@nuxt/content-th…</span></p>
52+
/// </div>
53+
///
54+
/// <div class="f6 text-gray mt-2">
55+
/// 10
56+
/// comments
57+
/// </div>
58+
/// </div>
59+
/// </div>
60+
class TimelineCard extends StatelessWidget {
61+
@override
62+
Widget build(BuildContext context) {
63+
return Container(
64+
decoration: BoxDecoration(),
65+
);
66+
}
67+
}
68+
69+
/// a indicator used at github activity timeline
70+
/// <span class="discussion-item-icon">
71+
/// <svg class="octicon octicon-eye" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"></path></svg>
72+
/// </span>
73+
class DiscussionItemIcon extends StatelessWidget {
74+
@override
75+
Widget build(BuildContext context) {
76+
return Container(
77+
decoration: BoxDecoration(
78+
borderRadius: BorderRadius.all(Radius.circular(32)),
79+
color: Colors.grey),
80+
child: Icon(Icons.fiber_manual_record),
81+
);
82+
}
83+
}
84+
85+
/// timeline date indicator by github
86+
/// <h3 class="profile-timeline-month-heading bg-white d-inline-block h6 pr-2 py-1">
87+
/// August <span class="text-gray">2020</span>
88+
/// </h3>
89+
class TimelineMonthHeading extends StatelessWidget {
90+
@override
91+
Widget build(BuildContext context) {
92+
return Text(
93+
"data",
94+
style: Theme.of(context).textTheme.headline3,
95+
);
96+
}
97+
}

example/lib/screen/plain_timeline_demo.dart

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:math';
2+
13
import 'package:flutter/material.dart';
24
import 'package:flutter_timeline/flutter_timeline.dart';
35
import 'package:flutter_timeline/timeline_theme.dart';
@@ -15,6 +17,7 @@ class _PlainTimelineDemoScreenState extends State<PlainTimelineDemoScreen> {
1517
void initState() {
1618
super.initState();
1719
events = [
20+
smallEventDisplay,
1821
plainEventDisplay,
1922
TimelineEventDisplay(
2023
child: Card(
@@ -41,13 +44,46 @@ class _PlainTimelineDemoScreenState extends State<PlainTimelineDemoScreen> {
4144
);
4245
}
4346

47+
TimelineEventDisplay get smallEventDisplay {
48+
return TimelineEventDisplay(
49+
child: Card(
50+
child: TimelineEventCard(
51+
title: Text("click the + button"),
52+
content: Text("to add a new event item"),
53+
),
54+
),
55+
indicatorSize: 12,
56+
indicator: Container(
57+
width: 12,
58+
height: 12,
59+
decoration: BoxDecoration(color: Colors.blueAccent),
60+
));
61+
}
62+
63+
Widget get randomIndicator {
64+
var candidates = [
65+
TimelineDots.of(context).circleIcon,
66+
Container(
67+
width: 16,
68+
height: 16,
69+
decoration: BoxDecoration(
70+
color: Colors.blueAccent,
71+
borderRadius: BorderRadius.all(Radius.circular(4)),
72+
),
73+
),
74+
];
75+
final _random = new Random();
76+
var element = candidates[_random.nextInt(candidates.length)];
77+
return element;
78+
}
79+
4480
TimelineEventDisplay get plainEventDisplay {
4581
return TimelineEventDisplay(
4682
child: TimelineEventCard(
4783
title: Text("just now"),
4884
content: Text("someone commented on your timeline ${DateTime.now()}"),
4985
),
50-
indicator: TimelineDots.of(context).circleIcon);
86+
indicator: randomIndicator);
5187
}
5288

5389
List<TimelineEventDisplay> events;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import 'package:flutter/material.dart';
2+
3+
ThemeData makeGithubTheme() =>
4+
new ThemeData(appBarTheme: AppBarTheme(color: Colors.black));

example/pubspec.lock

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.4.1"
10+
version: "2.4.2"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
1515
url: "https://pub.dartlang.org"
1616
source: hosted
1717
version: "2.0.0"
18+
characters:
19+
dependency: transitive
20+
description:
21+
name: characters
22+
url: "https://pub.dartlang.org"
23+
source: hosted
24+
version: "1.0.0"
1825
charcode:
1926
dependency: transitive
2027
description:
@@ -35,7 +42,14 @@ packages:
3542
name: collection
3643
url: "https://pub.dartlang.org"
3744
source: hosted
38-
version: "1.14.12"
45+
version: "1.14.13"
46+
expandable:
47+
dependency: "direct main"
48+
description:
49+
name: expandable
50+
url: "https://pub.dartlang.org"
51+
source: hosted
52+
version: "4.1.4"
3953
fake_async:
4054
dependency: transitive
4155
description:
@@ -59,14 +73,14 @@ packages:
5973
path: ".."
6074
relative: true
6175
source: path
62-
version: "0.0.4"
76+
version: "0.0.4+4"
6377
matcher:
6478
dependency: transitive
6579
description:
6680
name: matcher
6781
url: "https://pub.dartlang.org"
6882
source: hosted
69-
version: "0.12.6"
83+
version: "0.12.8"
7084
meta:
7185
dependency: transitive
7286
description:
@@ -99,7 +113,7 @@ packages:
99113
name: stack_trace
100114
url: "https://pub.dartlang.org"
101115
source: hosted
102-
version: "1.9.3"
116+
version: "1.9.5"
103117
stream_channel:
104118
dependency: transitive
105119
description:
@@ -127,14 +141,14 @@ packages:
127141
name: test_api
128142
url: "https://pub.dartlang.org"
129143
source: hosted
130-
version: "0.2.16"
144+
version: "0.2.17"
131145
typed_data:
132146
dependency: transitive
133147
description:
134148
name: typed_data
135149
url: "https://pub.dartlang.org"
136150
source: hosted
137-
version: "1.1.6"
151+
version: "1.2.0"
138152
vector_math:
139153
dependency: transitive
140154
description:
@@ -143,4 +157,5 @@ packages:
143157
source: hosted
144158
version: "2.0.8"
145159
sdks:
146-
dart: ">=2.7.0 <3.0.0"
160+
dart: ">=2.9.0-14.0.dev <3.0.0"
161+
flutter: ">=1.12.0 <2.0.0"

example/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ dependencies:
2727
flutter_timeline:
2828
path: "../"
2929

30+
expandable: ^4.1.4
31+
3032
dev_dependencies:
3133
flutter_test:
3234
sdk: flutter

lib/event_item.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ class TimelineEventDisplay {
44
TimelineEventDisplay(
55
{@required @required this.child,
66
this.indicator,
7+
this.indicatorSize,
78
this.forceLineDrawing = false});
89

910
final Widget child;
11+
12+
/// if not provided, use the default indicator size
13+
final double indicatorSize;
1014
final Widget indicator;
1115

1216
/// enables indicator line drawing even no indicator is passed.
@@ -15,6 +19,11 @@ class TimelineEventDisplay {
1519
bool get hasIndicator {
1620
return indicator != null;
1721
}
22+
23+
@override
24+
String toString() {
25+
return "Instance of TimelineEventDisplay:: indicator size = $indicatorSize";
26+
}
1827
}
1928

2029
class TimelineEventCard extends StatelessWidget {

lib/indicator_position.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enum IndicatorPosition{
2+
top,
3+
center,
4+
bottom
5+
}

0 commit comments

Comments
 (0)