Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor sample code to the ui kit #196

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ec5ddd4
refactor sample code to the ui kit
sachaarbonel Feb 1, 2022
12c43c8
pubspec: update dart constraints
sachaarbonel Feb 1, 2022
96f4ae8
format
sachaarbonel Feb 1, 2022
fb4f820
FollowingListView feedName
sachaarbonel Feb 1, 2022
5f956d1
FollowStatsWidget wip
sachaarbonel Feb 15, 2022
3f31c02
ui kit: FollowButton test
sachaarbonel Feb 15, 2022
ce93f18
ui kit: test FollowersListView
sachaarbonel Feb 15, 2022
0fefaa2
ui kit: FollowingListView test
sachaarbonel Feb 15, 2022
b8f3c06
Merge branch 'master' into ui-refactor-from-sample
sachaarbonel Feb 15, 2022
651dff8
fix lint
sachaarbonel Feb 15, 2022
08b8a48
llc: remove warning on getUser
sachaarbonel Feb 15, 2022
2ec7591
example: remove FollowingScreen
sachaarbonel Feb 15, 2022
9f72df4
ui kit: FollowStatsWidget InkWell
sachaarbonel Feb 15, 2022
7acfc1c
ComposeView -> ComposeScreen
sachaarbonel Feb 15, 2022
1359d49
bloc: add methods to fetch following/er user data
sachaarbonel Feb 15, 2022
d2a6de3
add FollowButton to Following/er ListView
sachaarbonel Feb 15, 2022
89ded0f
update docs
sachaarbonel Feb 16, 2022
7832dd1
format
sachaarbonel Feb 16, 2022
3762258
fix FollowersListView wip
sachaarbonel Feb 16, 2022
65b06e1
fix FollowingListView test
sachaarbonel Feb 16, 2022
7d218ed
remove StreamFeedTheme from test
sachaarbonel Feb 16, 2022
20efd50
weird failing test
sachaarbonel Feb 16, 2022
b621b11
ci: cheating
sachaarbonel Feb 25, 2022
84bbd0d
update docs + remove old typedefs (autocompletion fix)
sachaarbonel Feb 25, 2022
0ecae0e
Merge branch 'master' into ui-refactor-from-sample
sachaarbonel Feb 25, 2022
a831537
format
sachaarbonel Feb 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- uses: VeryGoodOpenSource/[email protected]
with:
path: packages/faye_dart/coverage/lcov.info
min_coverage: 49
min_coverage: 48
- uses: VeryGoodOpenSource/[email protected]
with:
path: packages/stream_feed_flutter_core/coverage/lcov.info
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,6 @@ class StreamFeedClientImpl implements StreamFeedClient {
@override
Future<User> getUser(String id, {bool withFollowCounts = false}) {
assert(_ensureCredentials(), '');
if (runner == Runner.client) {
_logger.warning('We advice using `client.getUser` only server-side');
}

final token =
userToken ?? TokenHelper.buildUsersToken(secret!, TokenAction.read);
Expand Down
137 changes: 4 additions & 133 deletions packages/stream_feed_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class _MyHomePageState extends State<MyHomePage> with StreamFeedMixin {
child: const Icon(Icons.edit_outlined),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ComposeView(
builder: (_) => ComposeScreen(
textEditingController: TextEditingController(),
),
fullscreenDialog: true,
Expand Down Expand Up @@ -552,67 +552,15 @@ class _ProfileScreenState extends State<ProfileScreen> with StreamFeedMixin {
style: Theme.of(context).textTheme.headline6,
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${widget.user?.followersCount ?? bloc.currentUser!.followersCount}',
style: Theme.of(context).textTheme.headline6,
),
Text(
'Followers',
style: Theme.of(context).textTheme.bodyText1,
),
],
),
Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${widget.user?.followingCount ?? bloc.currentUser!.followingCount}',
style: Theme.of(context).textTheme.headline6,
),
Text(
'Following',
style: Theme.of(context).textTheme.bodyText1,
),
],
),
],
),
FollowStatsWidget(user: widget.user),
if (widget.user != null &&
widget.user!.id != bloc.currentUser!.id) ...[
Row(
children: [
const SizedBox(width: 16),
Expanded(
child: FutureBuilder<bool>(
future: bloc.isFollowingFeed(
followerId: widget.user!.id!),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox.shrink();
} else {
return OutlinedButton(
child: Text(
snapshot.data! ? 'Unfollow' : 'Follow'),
onPressed: () async {
if (snapshot.data!) {
await bloc.unfollowFeed(
unfolloweeId: widget.user!.id!);
setState(() {});
} else {
await bloc.followFeed(
followeeId: widget.user!.id!);
setState(() {});
}
},
);
}
},
child: FollowButton(
user: widget.user,
),
),
const SizedBox(width: 8),
Expand Down Expand Up @@ -654,80 +602,3 @@ class _ProfileScreenState extends State<ProfileScreen> with StreamFeedMixin {
);
}
}

class FollowingScreen extends StatefulWidget {
const FollowingScreen({Key? key}) : super(key: key);

@override
State<FollowingScreen> createState() => _FollowingScreenState();
}

class _FollowingScreenState extends State<FollowingScreen>
with StreamFeedMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Following'),
),
body: FutureBuilder<List<Follow>>(
future: client.flatFeed('timeline', bloc.currentUser!.id).following(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(snapshot.data![index].feedId),
);
},
);
}
},
),
);
}
}

class FollowersScreen extends StatefulWidget {
const FollowersScreen({Key? key}) : super(key: key);

@override
State<FollowersScreen> createState() => _FollowersScreenState();
}

class _FollowersScreenState extends State<FollowersScreen>
with StreamFeedMixin {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Followers'),
),
body: FutureBuilder<List<Follow>>(
future: client.flatFeed('user', bloc.currentUser!.id).followers(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
} else {
return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
final feedName = snapshot.data![index].feedId.split(':').last;
return ListTile(
title: Text(feedName),
);
},
);
}
},
),
);
}
}
3 changes: 3 additions & 0 deletions packages/stream_feed_flutter/lib/src/media/media.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'fullscreen_media.dart';
export 'gallery_header.dart';
export 'gallery_preview.dart';
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export 'follow.dart';
export 'like.dart';
export 'reaction.dart';
export 'reply_button.dart';
export 'repost.dart';
44 changes: 44 additions & 0 deletions packages/stream_feed_flutter/lib/src/widgets/buttons/follow.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart';

/// A button to follow or unfollow a user
class FollowButton extends StatefulWidget {
const FollowButton({Key? key, this.user}) : super(key: key);
final User? user;

@override
_FollowButtonState createState() => _FollowButtonState();
}

class _FollowButtonState extends State<FollowButton> {
@override
Widget build(BuildContext context) {
return FutureBuilder<bool>(
future: FeedProvider.of(context)
.bloc
.isFollowingFeed(followerId: widget.user!.id!),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox.shrink();
} else {
return OutlinedButton(
child: Text(snapshot.data! ? 'Unfollow' : 'Follow'),
onPressed: () async {
if (snapshot.data!) {
await FeedProvider.of(context)
.bloc
.unfollowFeed(unfolloweeId: widget.user!.id!);
setState(() {});
} else {
await FeedProvider.of(context)
.bloc
.followFeed(followeeId: widget.user!.id!);
setState(() {});
}
},
);
}
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:stream_feed_flutter/src/theme/stream_feed_theme.dart';
import 'package:stream_feed_flutter/src/widgets/icons.dart';
import 'package:stream_feed_flutter/src/widgets/pages/compose_view.dart';
import 'package:stream_feed_flutter/src/widgets/pages/compose_screen.dart';
import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart';

// ignore_for_file: cascade_invocations
Expand Down Expand Up @@ -58,7 +58,7 @@ class ReplyButton extends StatelessWidget {
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ComposeView(
builder: (_) => ComposeScreen(
parentActivity: activity,
feedGroup: feedGroup,
textEditingController: TextEditingController(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import 'package:stream_feed_flutter/src/widgets/activity/activity.dart';
import 'package:stream_feed_flutter/src/widgets/buttons/reactive_elevated_button.dart';
import 'package:stream_feed_flutter/stream_feed_flutter.dart';

class ComposeView extends StatefulWidget {
const ComposeView(
/// A widget to react to an activity or compose a new activity.
class ComposeScreen extends StatefulWidget {
const ComposeScreen(
{Key? key,
this.parentActivity,
this.feedGroup = 'user',
Expand Down Expand Up @@ -36,10 +37,10 @@ class ComposeView extends StatefulWidget {
}

@override
State<ComposeView> createState() => _ComposeViewState();
State<ComposeScreen> createState() => _ComposeScreenState();
}

class _ComposeViewState extends State<ComposeView> {
class _ComposeScreenState extends State<ComposeScreen> {
bool get _isReply => widget.parentActivity != null;

String get _hintText =>
Expand Down
Loading