macOS widgets
This commit is contained in:
parent
118b392078
commit
275343445d
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/widget_model.dart';
|
||||
import 'package:invoiceninja_flutter/main_app.dart';
|
||||
|
|
@ -9,19 +10,21 @@ import 'package:widget_kit_plugin/widget_kit_plugin.dart';
|
|||
|
||||
import '../redux/app/app_state.dart';
|
||||
|
||||
void updateWidgetData() async {
|
||||
void updateWidgetData() {
|
||||
if (!isApple()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final context = navigatorKey.currentContext;
|
||||
final localization = AppLocalization.of(context);
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
WidgetsBinding.instance.addPostFrameCallback((duration) async {
|
||||
final context = navigatorKey.currentContext;
|
||||
final localization = AppLocalization.of(context);
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
|
||||
final json = jsonEncode(WidgetData.fromState(state, localization));
|
||||
final json = jsonEncode(WidgetData.fromState(state, localization));
|
||||
|
||||
await UserDefaults.setString(
|
||||
'widget_data', json, 'group.com.invoiceninja.app');
|
||||
await WidgetKit.reloadAllTimelines();
|
||||
await UserDefaults.setString(
|
||||
'widget_data', json, 'group.com.invoiceninja.app');
|
||||
await WidgetKit.reloadAllTimelines();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue