Skip to content

Commit

Permalink
Merge pull request LikeMindsCommunity#79 from LikeMindsCommunity/rele…
Browse files Browse the repository at this point in the history
…ase/v1.4.1

Release/v1.4.1
  • Loading branch information
AnujLM authored Jan 10, 2024
2 parents f0abbe4 + c99ad0a commit d9fb1c0
Show file tree
Hide file tree
Showing 16 changed files with 1,076 additions and 48 deletions.
5 changes: 4 additions & 1 deletion example/lib/cred_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:likeminds_feed_ss_sample/bloc_observer/routing_bloc_listener.dar
import 'package:likeminds_feed_ss_sample/likeminds_callback.dart';
import 'package:likeminds_feed_ss_sample/main.dart';
import 'package:likeminds_feed_ss_sample/network_handling.dart';
import 'package:likeminds_feed_ss_sample/screens/root_screen.dart';
import 'package:overlay_support/overlay_support.dart';
import 'package:uni_links/uni_links.dart';

Expand Down Expand Up @@ -283,7 +284,9 @@ class _CredScreenState extends State<CredScreen> {
// }
MaterialPageRoute route = MaterialPageRoute(
// INIT - Get the LMFeed instance and pass the credentials (if any)
builder: (context) => lmFeed!,
builder: (context) => TabApp(
feedWidget: lmFeed!,
),
);
Navigator.of(context).pushReplacement(route);
},
Expand Down
37 changes: 37 additions & 0 deletions example/lib/screens/activity_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:likeminds_feed_ss_fl/likeminds_feed_ss_fl.dart';

class ActivityScreen extends StatefulWidget {
const ActivityScreen({
super.key,
});

@override
State<ActivityScreen> createState() => _ActivityScreenState();
}

class _ActivityScreenState extends State<ActivityScreen> {
late String userId;
@override
void initState() {
userId = UserLocalPreference.instance
.fetchUserData()
.sdkClientInfo!
.userUniqueId;
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
// backgroundColor: ColorTheme.backgroundColor,
appBar: AppBar(
title: const Text('My Activity'),
// backgroundColor: ColorTheme.backgroundColor,
),
body: SSActivityWidget(
uuid: userId,
),
);
}
}
91 changes: 91 additions & 0 deletions example/lib/screens/root_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import 'package:likeminds_feed_ss_sample/screens/activity_screen.dart';

class TabApp extends StatefulWidget {
final Widget feedWidget;
const TabApp({
super.key,
required this.feedWidget,
});

@override
State<TabApp> createState() => _TabAppState();
}

class _TabAppState extends State<TabApp> with TickerProviderStateMixin {
late TabController tabController;

@override
void initState() {
// TODO: implement initState
super.initState();
tabController = TabController(length: 2, vsync: this);
tabController.addListener(() {
setState(() {});
});
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
bottomNavigationBar: NavigationBar(
selectedIndex: tabController.index,
onDestinationSelected: (index) {
tabController.animateTo(index);
setState(() {});
},
elevation: 10,
indicatorColor: const Color(0xFF3B82F6),
backgroundColor: const Color(0xFF3B82F6).withOpacity(0.1),
destinations: const [
NavigationDestination(
icon: Icon(
Icons.home,
),
selectedIcon: Icon(
Icons.home,
color: Colors.white,
),
label: 'Home',
),
NavigationDestination(
icon: Icon(
Icons.person_2_sharp,
),
selectedIcon: Icon(
Icons.person_2_sharp,
color: Colors.white,
),
label: 'Activity',
),
],
),
body: TabBarView(
controller: tabController,
children: [
HomeScreen(
feedWidget: widget.feedWidget,
), // First tab content
const ActivityScreen(
), // Second tab content
],
),
),
);
}
}

class HomeScreen extends StatelessWidget {
final Widget feedWidget;

const HomeScreen({
super.key,
required this.feedWidget,
});

@override
Widget build(BuildContext context) {
return feedWidget;
}
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.4.0
version: 1.4.1

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
10 changes: 10 additions & 0 deletions lib/assets/icons/mistery-box.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/likeminds_feed_ss_fl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export 'src/utils/share/share_post.dart';
export 'src/utils/local_preference/user_local_preference.dart';
export 'src/blocs/bloc.dart';
export 'src/utils/deep_link/deep_link_handler.dart';
export 'src/widgets/widgets.dart';

/// Flutter environment manager v0.0.1
const prodFlag = !bool.fromEnvironment('DEBUG');
Expand Down
2 changes: 1 addition & 1 deletion lib/packages/flutter_typeahead-4.3.7/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
flutter:
sdk: flutter
flutter_keyboard_visibility: ^5.4.0
extended_text_field: 12.1.0
extended_text_field: 13.0.0

dev_dependencies:
flutter_test:
Expand Down
105 changes: 105 additions & 0 deletions lib/src/utils/activity/activity_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import 'package:likeminds_feed/likeminds_feed.dart';
import 'package:likeminds_feed_ss_fl/src/utils/constants/ui_constants.dart';
import 'package:likeminds_feed_ui_fl/likeminds_feed_ui_fl.dart';
import 'package:flutter/material.dart';

class ActivityUtils {
static const String notificationTagRoute =
r'<<([^<>]+)\|route://([^<>]+)/([a-zA-Z-0-9_]+)>>';

static Map<String, String> decodeNotificationString(
String string, String currentUserId) {
Map<String, String> result = {};
final Iterable<RegExpMatch> matches =
RegExp(notificationTagRoute).allMatches(string);
for (final match in matches) {
String tag = match.group(1)!;
final String mid = match.group(2)!;
final String id = match.group(3)!;
if (id == currentUserId) {
tag = 'You';
}
string = string.replaceAll('<<$tag|route://$mid/$id>>', '@$tag');
result.addAll({tag: id});
}
return result;
}

static List<TextSpan> extractNotificationTags(
String text, String currentUserId) {
List<TextSpan> textSpans = [];
final Iterable<RegExpMatch> matches =
RegExp(notificationTagRoute).allMatches(text);
int lastIndex = 0;
for (Match match in matches) {
int startIndex = match.start;
int endIndex = match.end;
String? link = match.group(0);

if (lastIndex != startIndex) {
// Add a TextSpan for the preceding text
textSpans.add(
TextSpan(
text: text.substring(lastIndex, startIndex),
style: const TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14,
color: LMThemeData.kGrey1Color,
),
),
);
}
// Add a TextSpan for the URL
textSpans.add(
TextSpan(
text: decodeNotificationString(link!, currentUserId).keys.first,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
color: LMThemeData.kGrey1Color,
),
),
);

lastIndex = endIndex;
}

if (lastIndex != text.length) {
// Add a TextSpan for the remaining text
textSpans.add(TextSpan(
text: text.substring(lastIndex),
style: const TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14,
color: LMThemeData.kGrey1Color,
),
));
}

return textSpans;
}

static PostViewData postViewDataFromActivity(UserActivityItem activity) {
return activity.action == 7
? PostViewData.fromPost(post: activity.activityEntityData.postData!)
: (PostViewDataBuilder()
..id(activity.activityEntityData.id)
..isEdited(activity.activityEntityData.isEdited!)
..text(activity.activityEntityData.text)
..attachments(activity.activityEntityData.attachments!)
..communityId(activity.activityEntityData.communityId)
..isPinned(activity.activityEntityData.isPinned!)
..topics(activity.activityEntityData.topics!)
..userId(activity.activityEntityData.userId!)
..likeCount(activity.activityEntityData.likesCount!)
..commentCount(activity.activityEntityData.commentsCount!)
..isSaved(activity.activityEntityData.isSaved!)
..isLiked(activity.activityEntityData.isLiked!)
..menuItems(activity.activityEntityData.menuItems!)
..createdAt(DateTime.fromMillisecondsSinceEpoch(
activity.activityEntityData.createdAt))
..updatedAt(DateTime.fromMillisecondsSinceEpoch(
activity.activityEntityData.updatedAt!)))
.build();
}
}
2 changes: 2 additions & 0 deletions lib/src/utils/constants/assets_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const String kAssetPDFIcon =
"packages/likeminds_feed_ss_fl/assets/icons/pdf.svg";
const String kAssetChatIcon =
"packages/likeminds_feed_ss_fl/assets/icons/chat_lines.svg";
const String kAssetNoPostsIcon =
"packages/likeminds_feed_ss_fl/assets/icons/mistery-box.svg";

const List<String> svgAssets = [
kAssetDocPDFIcon,
Expand Down
Loading

0 comments on commit d9fb1c0

Please sign in to comment.