Skip to content

Commit

Permalink
Merge pull request #14 from noxasch/13-creating-multiple-widget-overr…
Browse files Browse the repository at this point in the history
…ide-existing-widget-click-event-data

13 creating multiple widget override existing widget click event data
  • Loading branch information
noxasch authored Sep 22, 2022
2 parents 7886769 + cbae1da commit 4f5ddd2
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 19 deletions.
4 changes: 4 additions & 0 deletions app_widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.1

* fix(android): onClickWidget callback should be independent on each widget

## 0.2.0

* rename interface into more generic
Expand Down
31 changes: 19 additions & 12 deletions app_widget/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:convert';
import 'dart:math';

import 'package:flutter/material.dart';

import 'package:app_widget/app_widget.dart';
Expand Down Expand Up @@ -124,12 +127,14 @@ class UpdateWidgetButton extends StatelessWidget {

// send configure
await _appWidgetPlugin.updateWidget(
widgetId: widgetId,
widgetLayout: 'example_layout',
textViews: {
'widget_title': 'App Widget',
'widget_message': 'Updated in flutter'
});
widgetId: widgetId,
widgetLayout: 'example_layout',
textViews: {
'widget_title': 'App Widget',
'widget_message': 'Updated in flutter'
},
payload: jsonEncode({'number': Random.secure().nextInt(10)}),
);
}
},
child: const Text('Update Widget'),
Expand Down Expand Up @@ -254,12 +259,14 @@ class ConfigureButton extends StatelessWidget {

// send configure
await _appWidgetPlugin.configureWidget(
widgetId: _widgetId!,
widgetLayout: 'example_layout',
textViews: {
'widget_title': 'App Widget',
'widget_message': 'Configured in flutter'
});
widgetId: _widgetId!,
widgetLayout: 'example_layout',
textViews: {
'widget_title': 'App Widget',
'widget_message': 'Configured in flutter'
},
payload: jsonEncode({'number': Random().nextInt(10)}),
);
messenger.showSnackBar(
const SnackBar(content: Text('Widget has been configured!')));
} else {
Expand Down
4 changes: 2 additions & 2 deletions app_widget/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.0"
version: "0.2.1"
app_widget_android:
dependency: transitive
description:
name: app_widget_android
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
version: "0.2.1"
app_widget_platform_interface:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions app_widget/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: app_widget
description: Flutter plugin to manage app widget / home screen widget from within flutter app.
version: 0.2.0
version: 0.2.1
homepage: https://noxasch.tech/
repository: https://github.com/noxasch/flutter_app_widget/tree/master/app_widget
issue_tracker: https://github.com/noxasch/flutter_app_widget/issues
Expand All @@ -14,7 +14,7 @@ dependencies:
sdk: flutter
plugin_platform_interface: ^2.0.2
app_widget_platform_interface: ^0.2.0
app_widget_android: ^0.2.0
app_widget_android: ^0.2.1
# app_widget_platform_interface: # local dev
# path: ../app_widget_platform_interface
# app_widget_android: # local dev
Expand Down
4 changes: 4 additions & 0 deletions app_widget_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.1

* fix(android): onClickWidget callback should be independent on each widget

## 0.2.0

* breaking changes: `androidAppName` renamed to `androidPackageName`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class AppWidgetMethodCallHandler(private val context: Context, )
pendingIntentFlag = pendingIntentFlag or PendingIntent.FLAG_IMMUTABLE
}

return PendingIntent.getActivity(context, 0, clickIntent, pendingIntentFlag)
return PendingIntent.getActivity(context, widgetId, clickIntent, pendingIntentFlag)
}

/// force reload the widget and this will trigger onUpdate in broadcast receiver
Expand Down
2 changes: 1 addition & 1 deletion app_widget_android/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.0"
version: "0.2.1"
app_widget_platform_interface:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion app_widget_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: app_widget_android
description: Android implementation for app_widget plugin
version: 0.2.0
version: 0.2.1
homepage: https://noxasch.tech/
repository: https://github.com/noxasch/flutter_app_widget/tree/master/app_widget_android
issue_tracker: https://github.com/noxasch/flutter_app_widget/issues
Expand Down

0 comments on commit 4f5ddd2

Please sign in to comment.