Skip to content

Commit 448dd6a

Browse files
committed
put the accent on docs convenient typedefs instead of generics
1 parent 652d0b0 commit 448dd6a

File tree

5 files changed

+121
-87
lines changed

5 files changed

+121
-87
lines changed

packages/stream_feed_flutter_core/lib/src/bloc/feed_bloc.dart

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,9 @@ import 'package:stream_feed_flutter_core/src/bloc/activities_controller.dart';
44
import 'package:stream_feed_flutter_core/src/bloc/reactions_controller.dart';
55
import 'package:stream_feed_flutter_core/src/extensions.dart';
66

7-
/// Widget dedicated to the state management of an app's Stream feed
8-
/// [GenericFeedBloc] is used to manage a set of operations
9-
/// associated with [GenericEnrichedActivity]s and [Reaction]s.
7+
/// The generic version of feedBloc
108
///
11-
/// [GenericFeedBloc] can be access at anytime by using the factory [of] method
12-
/// using Flutter's [BuildContext].
13-
///
14-
/// Usually what you want is the convenient [FeedBloc] that already
15-
/// has the default parameters defined for you
16-
/// suitable to most use cases
17-
///
18-
/// ## Usage
19-
/// - query the activities stream. Checkout our core widget [FlatFeedCore]
20-
/// to display activities
21-
/// - query the reactions stream (like, retweet, claps). Checkout our core widget [ReactionListCore]
22-
/// to display reactions
23-
/// - add activities (a tweet for example) in a reactive way
24-
/// ```dart
25-
/// FeedProvider.of(context).bloc.onAddActivity()
26-
/// ```
27-
/// - remove activities (delete a tweet)
28-
/// ```dart
29-
/// FeedProvider.of(context).bloc.onRemoveActivity()
30-
/// ```
31-
/// - add reactions (comment under a tweet)
32-
/// ```dart
33-
/// FeedProvider.of(context).bloc.onAddReaction()
34-
/// ```
35-
/// - remove reacitons (delete a comment under a tweet)
36-
/// ```dart
37-
/// FeedProvider.of(context).bloc.onRemoveReaction()
38-
/// ```
39-
/// - add child reactions (like to a comment)
40-
/// ```dart
41-
/// FeedProvider.of(context).bloc.onAddReaction()
42-
/// ```
43-
/// - remove child reacitons (unlike a comment)
44-
/// ```dart
45-
/// FeedProvider.of(context).bloc.onRemoveChildReaction()
46-
/// ```
9+
///{@macro feedBloc}
4710
4811
class GenericFeedBloc<A, Ob, T, Or> {
4912
GenericFeedBloc({required this.client, this.analyticsClient});

packages/stream_feed_flutter_core/lib/src/bloc/provider.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import 'package:flutter/foundation.dart';
22
import 'package:flutter/material.dart';
33
import 'package:stream_feed_flutter_core/src/bloc/feed_bloc.dart';
44

5-
/// Inherited widget providing the [GenericFeedBloc] to the widget tree
6-
/// Usually what you need is the convenient [FeedProvider] that already
7-
/// has the default parameters defined for you
8-
/// suitable to most usecases
5+
/// The generic version of [FeedProvider]
6+
///
7+
///{@macro feedProvider}
98
class GenericFeedProvider<A, Ob, T, Or> extends InheritedWidget {
109
const GenericFeedProvider({
1110
Key? key,

packages/stream_feed_flutter_core/lib/src/flat_feed_core.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@ import 'package:stream_feed_flutter_core/src/states/states.dart';
77
import 'package:stream_feed_flutter_core/src/typedefs.dart';
88
import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart';
99

10-
/// {@template genericFlatFeedCore}
11-
/// [GenericFlatFeedCore] is a simplified class that allows fetching a list of
12-
/// enriched activities (flat) while exposing UI builders.
13-
/// Make sure to have a [GenericFeedProvider] ancestor in order to provide the
14-
/// information about the activities.
15-
/// Usually what you want is the convenient [FlatFeedCore] that already
16-
/// has the default parameters defined for you
17-
/// suitable to most use cases
18-
/// {@endtemplate}
10+
/// The generic version of [FlatFeedCore]
11+
///
12+
///{@macro flatFeedCore}
1913
class GenericFlatFeedCore<A, Ob, T, Or> extends StatefulWidget {
14+
///{@macro flatFeedCore}
2015
const GenericFlatFeedCore({
2116
Key? key,
2217
required this.feedGroup,

packages/stream_feed_flutter_core/lib/src/reactions_list_core.dart

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,11 @@ import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart';
1010

1111
//TODO: other things to add to core: FollowListCore, UserListCore
1212

13-
/// [ReactionListCore] is a simplified class that allows fetching a list of
14-
/// reactions while exposing UI builders.
15-
///
16-
///
17-
/// ```dart
18-
/// class FlatActivityListPage extends StatelessWidget {
19-
/// @override
20-
/// Widget build(BuildContext context) {
21-
/// return Scaffold(
22-
/// body: ReactionListCore(
23-
/// onErrorWidget: Center(
24-
/// child: Text('An error has occurred'),
25-
/// ),
26-
/// onEmptyWidget: Center(
27-
/// child: Text('Nothing here...'),
28-
/// ),
29-
/// onProgressWidget: Center(
30-
/// child: CircularProgressIndicator(),
31-
/// ),
32-
/// feedBuilder: (context, reactions, idx) {
33-
/// return YourReactionWidget(reaction: reactions[idx]);
34-
/// }
35-
/// ),
36-
/// );
37-
/// }
38-
/// }
39-
/// ```
40-
///
41-
/// Make sure to have a [GenericFeedProvider] ancestor in order to provide the
42-
/// information about the reactions.
13+
/// The generic version of [ReactionListCore]
14+
///
15+
///{@macro reactionListCore}
4316
class GenericReactionListCore<A, Ob, T, Or> extends StatefulWidget {
17+
///{@macro reactionListCore}
4418
const GenericReactionListCore({
4519
Key? key,
4620
required this.reactionsBuilder,

packages/stream_feed_flutter_core/lib/src/typedefs.dart

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:stream_feed_flutter_core/src/bloc/bloc.dart';
33
import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart';
44

5+
/* BUILDERS */
56
/// {@template enrichedFeedBuilder}
67
/// A builder that allows building a ListView of EnrichedActivity based Widgets
78
/// {@endtemplate}
@@ -17,13 +18,24 @@ typedef EnrichedFeedBuilder<A, Ob, T, Or> = Widget Function(
1718
typedef ReactionsBuilder = Widget Function(
1819
BuildContext context, List<Reaction> reactions, int idx);
1920

20-
/* Convenient typedefs for defining default type parameters
21+
/* CONVENIENT TYPEDEFS
22+
for defining default type parameters.
2123
Dart doesn't allow a type parameter to have a default value
22-
so this is hack until it is supported
24+
so this is a hack until it is supported
2325
*/
2426

25-
/// {@template flatFeedCore}
2627
///Convenient typedef for [GenericFlatFeedCore] with default parameters
28+
///
29+
/// {@template flatFeedCore}
30+
/// [FlatFeedCore] is a core class that allows fetching a list of
31+
/// enriched activities (flat) while exposing UI builders.
32+
/// Make sure to have a [FeedProvider] ancestor in order to provide the
33+
/// information about the activities.
34+
/// Usually what you want is the convenient [FlatFeedCore] that already
35+
/// has the default parameters defined for you
36+
/// suitable to most use cases. But if you need a
37+
/// more advanced use case use [GenericFlatFeedCore] instead
38+
///
2739
/// ## Usage
2840
///
2941
/// ```dart
@@ -53,11 +65,102 @@ typedef ReactionsBuilder = Widget Function(
5365
typedef FlatFeedCore = GenericFlatFeedCore<User, String, String, String>;
5466

5567
///Convenient typedef for [GenericReactionListCore] with default parameters
68+
///
69+
/// {@template reactionListCore}
70+
/// [ReactionListCore] is a core class that allows fetching a list of
71+
/// reactions while exposing UI builders.
72+
///
73+
/// ## Usage
74+
///
75+
/// ```dart
76+
/// class FlatActivityListPage extends StatelessWidget {
77+
/// @override
78+
/// Widget build(BuildContext context) {
79+
/// return Scaffold(
80+
/// body: ReactionListCore(
81+
/// onErrorWidget: Center(
82+
/// child: Text('An error has occurred'),
83+
/// ),
84+
/// onEmptyWidget: Center(
85+
/// child: Text('Nothing here...'),
86+
/// ),
87+
/// onProgressWidget: Center(
88+
/// child: CircularProgressIndicator(),
89+
/// ),
90+
/// feedBuilder: (context, reactions, idx) {
91+
/// return YourReactionWidget(reaction: reactions[idx]);
92+
/// }
93+
/// ),
94+
/// );
95+
/// }
96+
/// }
97+
/// ```
98+
///
99+
/// Make sure to have a [FeedProvider] ancestor in order to provide the
100+
/// information about the reactions.
101+
///
102+
/// Usually what you want is the convenient [ReactionListCore] that already
103+
/// has the default parameters defined for you
104+
/// suitable to most use cases. But if you need a
105+
/// more advanced use case use [GenericReactionListCore] instead
106+
/// {@endtemplate}
56107
typedef ReactionListCore
57108
= GenericReactionListCore<User, String, String, String>;
58109

59-
///Convenient typedef for [GenericFeedProvider] with default parameters
110+
/// Convenient typedef for [GenericFeedProvider] with default parameters
111+
///
112+
/// {@template feedProvider}
113+
/// Inherited widget providing the [FeedBloc] to the widget tree
114+
/// Usually what you need is the convenient [FeedProvider] that already
115+
/// has the default parameters defined for you
116+
/// suitable to most usecases. But if you need a
117+
/// more advanced use case use [GenericFeedProvider] instead
118+
/// {@endtemplate}
60119
typedef FeedProvider = GenericFeedProvider<User, String, String, String>;
61120

62-
///Convenient typedef for [GenericFeedBloc] with default parameters
121+
/// Convenient typedef for [GenericFeedBloc] with default parameters
122+
///
123+
/// {@template feedBloc}
124+
/// Widget dedicated to the state management of an app's Stream feed
125+
/// [FeedBloc] is used to manage a set of operations
126+
/// associated with [EnrichedActivity]s and [Reaction]s.
127+
///
128+
/// [FeedBloc] can be access at anytime by using the factory [of] method
129+
/// using Flutter's [BuildContext].
130+
///
131+
/// Usually what you want is the convenient [FeedBloc] that already
132+
/// has the default parameters defined for you
133+
/// suitable to most use cases. But if you need a
134+
/// more advanced use case use [GenericFeedBloc] instead
135+
///
136+
/// ## Usage
137+
/// - query the activities stream. Checkout our core widget [FlatFeedCore]
138+
/// to display activities
139+
/// - query the reactions stream (like, retweet, claps). Checkout our core widget
140+
/// [ReactionListCore] for displaying reactions
141+
/// - add activities (a tweet for example) in a reactive way
142+
/// ```dart
143+
/// FeedProvider.of(context).bloc.onAddActivity()
144+
/// ```
145+
/// - remove activities (delete a tweet) in a reactive way
146+
/// ```dart
147+
/// FeedProvider.of(context).bloc.onRemoveActivity()
148+
/// ```
149+
/// - add reactions (comment under a tweet) in a reactive way
150+
/// ```dart
151+
/// FeedProvider.of(context).bloc.onAddReaction()
152+
/// ```
153+
/// - remove reacitons (delete a comment under a tweet) in a reactive way
154+
/// ```dart
155+
/// FeedProvider.of(context).bloc.onRemoveReaction()
156+
/// ```
157+
/// - add child reactions (like to a comment) in a reactive way
158+
/// ```dart
159+
/// FeedProvider.of(context).bloc.onAddReaction()
160+
/// ```
161+
/// - remove child reacitons (unlike a comment) in a reactive way
162+
/// ```dart
163+
/// FeedProvider.of(context).bloc.onRemoveChildReaction()
164+
/// ```
165+
/// {@endtemplate}
63166
typedef FeedBloc = GenericFeedBloc<User, String, String, String>;

0 commit comments

Comments
 (0)