Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
119 changes: 119 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Publish sirenapp_flutter_inbox in pub.dev

on:
workflow_dispatch:
inputs:
ReleaseType:
description: 'Release Type'
required: true
default: 'Patch'
type: choice
options:
- "Major"
- "Minor"
- "Patch"


jobs:
publish:
permissions:
id-token: write # Required for authentication using OIDC
contents: write
runs-on: ubuntu-latest
steps:
- name: Get branch names.
id: branch-names
uses: tj-actions/branch-names@v8

- name: Checkout code
uses: actions/checkout@v4

- name: Set up Git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
export BRANCH=${{ steps.branch-names.outputs.current_branch }}
echo "branch: $BRANCH"
if [[ "$BRANCH" != "master" ]]; then
echo "Tagging cannot be done on a branch other than master"
echo $BRANCH
exit 1
fi
export VERSION=$(cat pubspec.yaml | grep "version:" | awk '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')
echo $VERSION
export UPDATE_CHOICE=${{ inputs.ReleaseType }}
export MAJOR=$(echo $VERSION | cut -d. -f1)
export MINOR=$(echo $VERSION | cut -d. -f2)
export PATCH=$(echo $VERSION | cut -d"+" -f1 | cut -d"." -f3)
if [[ "$UPDATE_CHOICE" == "Major" ]]; then export NEW_TAG=$((MAJOR + 1)).0.0; fi
if [[ "$UPDATE_CHOICE" == "Minor" ]]; then export NEW_TAG=$MAJOR.$((MINOR + 1)).0; fi
if [[ "$UPDATE_CHOICE" == "Patch" ]]; then export NEW_TAG=$MAJOR.$MINOR.$((PATCH + 1)); fi
echo NEW_TAG $NEW_TAG
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
sed -i "s/version: $VERSION/version: $NEW_TAG/g" pubspec.yaml

- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
channel: 'stable'

- name: Exclude Example application
run: rm -rf example

- name: Install dependencies
run: flutter pub get

- name: Analyze project source
run: flutter analyze lib/

- name: Run tests
run: flutter test lib/

- name: Setup Pub Credentials
shell: bash
env:
INPUT_ACCESS_TOKEN: ${{ secrets.INPUT_ACCESS_TOKEN }}
INPUT_REFRESH_TOKEN: ${{ secrets.INPUT_REFRESH_TOKEN }}
run: |
sh ./pub_login.sh

- name: Check Publish Warnings
run: flutter pub publish --dry-run

- name: Publish Package
run: flutter pub publish -f

- name: Commit pubspec.yaml
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_TAG: ${{ env.NEW_TAG }}
run: |
git add pubspec.yaml
git commit -m "Version bumped to $NEW_TAG"
git push origin $BRANCH

- name: Create New Tag
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_TAG: ${{ env.NEW_TAG }}
run: |
git tag v${{ env.NEW_TAG }}
git push origin v${{ env.NEW_TAG }}


- name: Create GitHub release
if: success()
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_TAG: ${{ env.NEW_TAG }}
with:
tag_name: v${{ env.NEW_TAG }}
release_name: Release v${{ env.NEW_TAG }}
draft: false
prerelease: false

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ migrate_working_dir/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
build/
coverage/

13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## 1.2.0

### Added
- Support for tab-based categorization, tabular styles and formats exposure.


## 1.1.0

### Added
Expand All @@ -15,9 +21,4 @@ All notable changes to this project will be documented in this file.
This is the first public release of the package.

### Added
- Flutter UI kit for displaying and managing in-app notifications.





- Flutter UI kit for displaying and managing in-app notifications.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ Given below are the arguments of Siren Inbox Widget.
| Arguments | Description | Type | Default value |
| ----------------- | -------------------------------------------------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| darkMode | Toggle to enable dark mode when custom theme is not passed | bool | false |
| hideTab | Toggle to enable all and unread tabs | bool | false |
| itemsPerFetch | Number of notifications fetch per api request (have a max cap of 50) | int | 20 |
| listEmptyWidget | Custom widget for empty notification list | Widget | null |
| customCard | Custom widget to display the notification cards | Widget | null |
| customLoader | Custom widget to display the initial loading state | Widget | null |
| customErrorWidget | Custom error widget | Widget | null |
| cardParams | Properties of notification card | CardParams | CardParams(hideAvatar: false, disableAutoMarkAsRead: false, hideDelete: false, deleteIcon: Icon(Icons.close), onAvatarClick: Function(NotificationType), hideMediaThumbnail: false, onMediaThumbnailClick: Function(NotificationType)) |
| headerParams | Properties of notification window header | HeaderParams | HeaderParams(hideHeader: false, hideClearAll: false,title: 'Notifications', customHeader: null showBackButton:false, backButton: null, onBackPress: ()=> null ) |
| tabParams | Properties of tab bar | TabParams | TabParams(tabs: [TabItem(key: 'ALL', title: 'All'), TabItem(key: 'UNREAD', title: 'Unread')], activeTabIndex:0,) |
| onCardClick | Custom click handler for notification cards | Function(NotificationType) | null |
| onError | Callback for handling errors | Function(SirenErrorType) | null |
| theme | Theme properties for custom color theme | CustomThemeColors | null |
Expand Down
2 changes: 1 addition & 1 deletion env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
API_DOMAIN = https://api.sirenapp.io/api/
API_DOMAIN = https://api.trysiren.io/api/
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.1.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
4 changes: 4 additions & 0 deletions lib/src/api/fetch_all_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class FetchAllNotifications {
queryParams['start'] = start;
}

if (isRead != null) {
queryParams['isRead'] = isRead.toString();
}

final queryString =
queryParams.entries.map((e) => '${e.key}=${e.value}').join('&');

Expand Down
6 changes: 5 additions & 1 deletion lib/src/api/notifications_bulk_update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ class NotificationsBulkUpdate {
Future<ApiResponse> notificationsBulkUpdate({
required Map<String, dynamic> data,
required String operation,
bool? isRead,
}) async {
final api = ApiClient(apiProvider());
final apiPath =
var apiPath =
'${Generics.V2}${Generics.BASE_URL}${SirenDataProvider.instance.recipientId}/notifications/bulk-update';
if (isRead != null) {
apiPath = '$apiPath?isRead=$isRead';
}
final result = ApiResponse()..isLoading;
var apiError = Errors.markAsReadFailedError;

Expand Down
14 changes: 14 additions & 0 deletions lib/src/constants/generics.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'package:sirenapp_flutter_inbox/src/constants/strings.dart';
import 'package:sirenapp_flutter_inbox/src/models/ui_models.dart';

class Generics {
Generics._();

Expand All @@ -9,6 +12,15 @@ class Generics {
static const int AVERAGE_ITEMS_ON_SCREEN = 7;
static const int MAX_RETRIES = 2;
static const String ENV_PATH = 'packages/sirenapp_flutter_inbox/env';

static final inboxTabs = [
TabItem(key: InboxTabs.ALL.name, title: Strings.tabAll),
TabItem(key: InboxTabs.UNREAD.name, title: Strings.tabUnread),
];
static final List<String> emptyMessages = [
Strings.empty_title,
Strings.empty_title_unread,
];
}

enum Status {
Expand All @@ -19,6 +31,8 @@ enum Status {
INVALID_CREDENTIALS,
}

enum InboxTabs { ALL, UNREAD }

enum BulkUpdateType {
MARK_AS_READ,
MARK_AS_DELETED,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/constants/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Strings {
Strings._();

static const empty_title = 'No new notifications';
static const empty_title_unread = 'No unread notifications';
static const empty_desc = 'Check back later for updates and alerts.';
static const error_title = 'Oops! Something went wrong.';
static const something_went_wrong = 'Something went wrong';
Expand Down Expand Up @@ -29,4 +30,6 @@ class Strings {
'This operation require valid credentials';
static const invalidCredentialsError =
'Invalid credentials found. Please check your token and recipient ID';
static const tabAll = 'All';
static const tabUnread = 'Unread';
}
9 changes: 6 additions & 3 deletions lib/src/models/notification_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ class MessageData {
thumbnailUrl: json?['thumbnailUrl'] != null
? (json?['thumbnailUrl'] as String?)
: '',
additionalData: json?['additionalData'] as String?,
additionalData:
(json?['additionalData'] != null && json?['additionalData'] is Map)
? json!['additionalData'] as Map<String, dynamic>?
: null,
);
}

Expand All @@ -100,9 +103,9 @@ class MessageData {
final AvatarData? avatar;

/// Additional data related to the message.
final String? additionalData;
final Map<String, dynamic>? additionalData;

/// The thumbnail URL associated with the message to display
/// The thumbnail URL associated with the message to display.
final String? thumbnailUrl;
}

Expand Down
Loading