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