From 8966877859c6b65128101180bbed67fe9069c1bf Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:13:42 +0100 Subject: [PATCH 01/12] update and fix methods --- lib/src/activsy.dart | 134 ++++++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 60 deletions(-) diff --git a/lib/src/activsy.dart b/lib/src/activsy.dart index aac15a3..d714bd2 100644 --- a/lib/src/activsy.dart +++ b/lib/src/activsy.dart @@ -4,105 +4,119 @@ import 'dart:async'; import 'dart:developer'; +import 'package:flutter/cupertino.dart'; + class Activsy { + Activsy._() { + _instance = this; + } + Timer? _timer; - /// [_seconds] timer wait time - late int _seconds; + /// [_waiTime] timer wait time + int _waiTime = 0; - bool _showLog = true; + static bool _initialized = false; - /// return function that will be invoked when the timer is equals to 0 [_callback] - void Function()? _callback; + static Activsy? _instance; - static final Activsy _instance = Activsy._internal(); + late void Function() _callback; - Activsy._internal(); + /// [initialize] Initialize the activity monitor, + /// all methods threw exception if they are called before this method + factory Activsy.initialize( + {required int waiTime, required Function() onTimeOut}) { + assert(waiTime <= 30, "Standby time should not be more than 30 seconds"); - /// function responsible for setting the return method after the end of the timer [config] - factory Activsy.config( - {required int seconds, - bool showLog = true, - required Function() noActivity}) { - assert(seconds >= 2); - _instance._showLog = showLog; - _instance._seconds = seconds; - _instance._callback = noActivity; - return _instance; + _initialized = true; + _instance = _instance ?? Activsy._(); + _instance!._waiTime = waiTime; + _instance!._callback = onTimeOut; + + return _instance!; } - /// init timer - void init() { - start(); + /// [_trigger] Notify the time exceeded + /// Note: This method only works when monitoring is active + static void _trigger() { + if (!_initialized) { + throw Exception('this function to be called after the initialize method'); + } + _instance!._callback(); } - /// start and set the timer [start] - /// this function to be called after the [config] method - /// otherwise you will throw an exception + /// [start] Activity monitoring start + /// Note: This method only works when monitoring is nat active static void start() { - if (_instance._showLog) log('activsy::start', time: DateTime.now()); - - if (_instance._callback == null) - throw Exception('this function to be called after the config method'); - - var timer = _instance._timer; + if (!_initialized) { + throw Exception('this function to be called after the initialize method'); + } - var seconds = _instance._seconds; + var timer = _instance!._timer; if (timer != null && timer.isActive) return; - _instance._timer = Timer(Duration(seconds: seconds), () { - _instance._callback!(); - _instance._timer = null; - }); + _instance!._timer = Timer(Duration(seconds: _instance!._waiTime), _trigger); } - /// stop the timer [cancel] - static void cancel() { - if (_instance._showLog) log('activsy::stop', time: DateTime.now()); + /// [stop] Cancel activity monitoring + /// Note: This method only works when monitoring is active + static void stop() { + if (!_initialized) { + throw Exception('this function to be called after the initialize method'); + } - var timer = _instance._timer; + if (_instance!._timer != null) _instance!._timer!.cancel(); - if (timer != null && timer.isActive) timer.cancel(); + _instance!._timer = null; } - /// restore timer [reset] - /// from the timer reset it can also change the seconds it must wait before triggering the [noActivity] - /// Note: seconds >= 2 - static void reset({int? seconds}) { - var _seconds = seconds ?? _instance._seconds; + /// restore timer [updateTime] + /// from the timer reset it can also change the seconds + /// it must wait before triggering the [onTimeOut] + /// Note: This method only works when monitoring is active and seconds <= 30 + static void updateTime({required int waiTime}) { + if (!_initialized) { + throw Exception('this function to be called after the initialize method'); + } - assert(_seconds >= 2); + assert(waiTime <= 30, "Standby time should not be more than 30 seconds"); - if (_instance._timer == null) return; + var timer = _instance!._timer; - if (_instance._showLog) log('activsy::reset', time: DateTime.now()); + if (timer == null || !timer.isActive) return; - _instance._seconds = _seconds; + _instance!._waiTime = waiTime; - cancel(); + stop(); start(); } - /// There are several reasons to trigger the noActivity method before the stipulated timer [trigger] - static void trigger() { - if (_instance._showLog) log('activsy::trigger', time: DateTime.now()); + /// Restores activity monitoring [reset] + /// Note: This method only works when monitoring is active + static void reset() { + if (!_initialized) { + throw Exception('this function to be called after the initialize method'); + } - if (_instance._callback == null) - throw Exception('this function to be called after the config method'); + if (_instance!._timer == null || !_instance!._timer!.isActive) return; - cancel(); + stop(); - _instance._callback!(); + start(); } - /// checks if the method has been configured [noActivity] - /// this function to be called after the [config] method + /// There are several reasons to trigger the [onTimeOut] + /// method before the stipulated timer [forceTimeOut] + static void forceTimeOut() => _trigger(); + + /// checks if the method has been configured [onTimeOut] + /// this function to be called after the [initialize] method /// otherwise you will throw an exception - static bool get isInitialized => _instance._callback != null; + static bool get isInitialized => _initialized; /// checks monitoring is active [isActive] static bool get isActive => - (_instance._timer != null && _instance._timer!.isActive); + (_instance!._timer != null && _instance!._timer!.isActive); } From ec305fc48c4033766896b39dab44a882fcd1658f Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:14:07 +0100 Subject: [PATCH 02/12] rename fields --- lib/src/activsy_widget.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/src/activsy_widget.dart b/lib/src/activsy_widget.dart index adfa090..ac5c043 100644 --- a/lib/src/activsy_widget.dart +++ b/lib/src/activsy_widget.dart @@ -7,18 +7,17 @@ class ActivsyWidget extends StatelessWidget { final Function(PointerEvent)? onEvent; - /// [detectedMouseAction] enable/disable mouse detector - final bool detectedMouseAction; + /// [withMouse] enable/disable mouse detector + final bool withMouse; ActivsyWidget( - {required this.builder, this.detectedMouseAction = false, this.onEvent}) + {required this.builder, this.withMouse = false, this.onEvent}) : assert(Activsy.isInitialized, () { throw FlutterError( - 'activsy no initialized.\nMust call the Activsy.config() before the ActivsyWidget'); - return true; + 'activsy no initialized.\nMust call the Activsy.initialize() before the ActivsyWidget'); }()); - /// notify when has event + /// [_onEvent] notify when has event void _onEvent(PointerEvent event) { Activsy.reset(); if (onEvent != null && Activsy.isActive) onEvent!(event); @@ -27,7 +26,7 @@ class ActivsyWidget extends StatelessWidget { /// sets up the widget to be shown [_builder] Widget _builder(BuildContext context) { // checks whether mouse event holding has been enabled - if (detectedMouseAction) { + if (withMouse) { return MouseRegion( child: builder(context), onEnter: _onEvent, From 6071d7a2327700cdaba3ce93b9264d3624cd57df Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:14:16 +0100 Subject: [PATCH 03/12] update test --- test/activsy_test.dart | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/test/activsy_test.dart b/test/activsy_test.dart index c2cb6e2..c6222b8 100644 --- a/test/activsy_test.dart +++ b/test/activsy_test.dart @@ -1,23 +1,19 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:activsy/activsy.dart'; void main() { - void noActivity() { - print('noActivity called'); - } - test('start monitor', () async { - Activsy.config(seconds: 2, noActivity: noActivity); + test('initializeTest', () async { + Activsy.initialize(waiTime: 3, onTimeOut: ()=> debugPrint("onTimeOut")); Activsy.start(); - Activsy.reset(seconds: 8); - Activsy.trigger(); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 5)); }); - test('no initialize failure', () async { + test('when not initialized', () async { Activsy.start(); }); } From d3af6c4c0f384e26202e2d61dceeba05539af794 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:14:29 +0100 Subject: [PATCH 04/12] update example --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 5 +- example/ios/Runner/Info.plist | 4 + example/lib/main.dart | 20 ++- example/lib/src/transactions.dart | 44 +++---- example/pubspec.lock | 123 +++++++++++-------- 6 files changed, 104 insertions(+), 94 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 4829c65..88d397a 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -171,10 +171,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -185,6 +187,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 5baf7a1..7f55346 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -43,5 +43,9 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/main.dart b/example/lib/main.dart index afce2bb..862b4e1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,14 +15,14 @@ class App extends StatefulWidget { class _AppState extends State { final GlobalKey _globalKey = GlobalKey(); - final int _seconds = 10; + final int _waiTime = 3; void onEvent(dynamic _) { - print('onEvent'); + debugPrint('onEvent'); } - void noActivity() async { - print('noActivity called :)'); + void onTimeOut() async { + debugPrint('onTimeOut :)'); await _globalKey.currentState!.pushNamed(AuthenticationPage.route); Activsy.start(); } @@ -30,13 +30,14 @@ class _AppState extends State { @override void initState() { super.initState(); - Activsy.config(seconds: _seconds, noActivity: noActivity).init(); + Activsy.initialize(waiTime: _waiTime, onTimeOut: onTimeOut); + Activsy.start(); } @override Widget build(BuildContext context) { return ActivsyWidget( - detectedMouseAction: false, + withMouse: true, onEvent: onEvent, builder: (ctx) { return MaterialApp( @@ -45,9 +46,8 @@ class _AppState extends State { theme: ThemeData( primarySwatch: Colors.blue, ), - initialRoute: TransactionsPage.route, + initialRoute: '/', onGenerateRoute: AppRouter.route, - home: TransactionsPage(), ); }, ); @@ -56,10 +56,8 @@ class _AppState extends State { abstract class AppRouter { static Route route(RouteSettings settings) { + debugPrint("route:: ${settings.name}"); switch (settings.name) { - case TransactionsPage.route: - return MaterialPageRoute(builder: (_) => TransactionsPage()); - case AuthenticationPage.route: return MaterialPageRoute(builder: (_) => AuthenticationPage()); default: diff --git a/example/lib/src/transactions.dart b/example/lib/src/transactions.dart index d235712..89d4751 100644 --- a/example/lib/src/transactions.dart +++ b/example/lib/src/transactions.dart @@ -10,7 +10,7 @@ class TransactionsPage extends StatefulWidget { } class _TransactionsPageState extends State { - ScrollController _controller = ScrollController(); + final ScrollController _controller = ScrollController(); List> _items = []; @@ -23,7 +23,7 @@ class _TransactionsPageState extends State { } void fetchData() async { - await Future.delayed(Duration(milliseconds: 300)); + await Future.delayed(const Duration(milliseconds: 300)); var list = List.generate(15, (index) => createItem()).toList(); setState(() => _items.addAll(list)); @@ -33,16 +33,12 @@ class _TransactionsPageState extends State { return ListView.separated( controller: _controller, itemCount: _items.length, - separatorBuilder: (ctx, index) { - return SizedBox( - height: 10.0, - ); - }, + separatorBuilder: (ctx, index) => const SizedBox(height: 10.0), itemBuilder: (ctx, index) { var item = _items[index]; return Container( - margin: EdgeInsets.only(left: 10.0, right: 10.0), - padding: EdgeInsets.all(8.0), + margin: const EdgeInsets.only(left: 10.0, right: 10.0), + padding: const EdgeInsets.all(8.0), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(4.0)), child: Row( @@ -52,30 +48,26 @@ class _TransactionsPageState extends State { color: item['color'], size: 32.0, ), - SizedBox( - width: 8.0, - ), + const SizedBox(width: 8.0), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( 'Payment n°:${index + 1}', - style: TextStyle(fontSize: 18.0), - ), - SizedBox( - height: 2.0, + style: const TextStyle(fontSize: 18.0), ), + const SizedBox(height: 2.0), Text.rich(TextSpan(children: [ TextSpan( text: "\$${item['amount']}", - style: TextStyle(fontSize: 14.0, color: Colors.grey)), - TextSpan( + style: const TextStyle(fontSize: 14.0, color: Colors.grey)), + const TextSpan( text: " • ", style: TextStyle(fontSize: 14.0, color: Colors.grey)), TextSpan( text: "${item['status']}", - style: TextStyle(fontSize: 14.0, color: Colors.grey)) + style: const TextStyle(fontSize: 14.0, color: Colors.grey)) ])) ], ) @@ -90,10 +82,10 @@ class _TransactionsPageState extends State { // TODO: implement initState super.initState(); - Future.delayed(Duration(seconds: 1), () { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text( - 'This application will be blocked after 10 seconds without user interaction '))); + Future.delayed(const Duration(milliseconds: 300), () { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar( + content: Text('This application will be blocked after 3 ' + 'seconds without user interaction '))); }); _controller.addListener(() { @@ -110,13 +102,11 @@ class _TransactionsPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Transactions'), + title: const Text('Transactions'), ), body: Column( children: [ - SizedBox( - height: 10, - ), + const SizedBox(height: 10), Expanded(child: _bodyList()) ], ), diff --git a/example/pubspec.lock b/example/pubspec.lock index f964853..8f30eb0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,63 +7,63 @@ packages: path: ".." relative: true source: path - version: "1.0.0" + version: "1.0.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.17.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted version: "1.0.5" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -73,7 +73,8 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493 + url: "https://pub.dev" source: hosted version: "1.0.4" flutter_test: @@ -81,46 +82,60 @@ packages: description: flutter source: sdk version: "0.0.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c + url: "https://pub.dev" source: hosted version: "1.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.8.3" pin_code_view: dependency: "direct main" description: name: pin_code_view - url: "https://pub.dartlang.org" + sha256: "5f23f03b94d282b3b726f7570ddc4fb3c2ba685db2fc8f2a0ca91b70e814ad72" + url: "https://pub.dev" source: hosted version: "0.3.0+2" sky_engine: @@ -132,58 +147,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.8.1" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.8" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.4" sdks: - dart: ">=2.16.2 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=1.17.0" From 846ea730ddea8e3a5fb03ee072ffdd1e939489f6 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:29:17 +0100 Subject: [PATCH 05/12] remove unused libs --- lib/src/activsy.dart | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/src/activsy.dart b/lib/src/activsy.dart index d714bd2..a1f6d93 100644 --- a/lib/src/activsy.dart +++ b/lib/src/activsy.dart @@ -2,10 +2,6 @@ library activsy; import 'dart:async'; -import 'dart:developer'; - -import 'package:flutter/cupertino.dart'; - class Activsy { Activsy._() { _instance = this; From a338428608cdca0cb1f3a3dc013fa52e73023b39 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:29:29 +0100 Subject: [PATCH 06/12] add key --- lib/src/activsy_widget.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/activsy_widget.dart b/lib/src/activsy_widget.dart index ac5c043..fae41b0 100644 --- a/lib/src/activsy_widget.dart +++ b/lib/src/activsy_widget.dart @@ -11,11 +11,12 @@ class ActivsyWidget extends StatelessWidget { final bool withMouse; ActivsyWidget( - {required this.builder, this.withMouse = false, this.onEvent}) + {Key? key, required this.builder, this.withMouse = false, this.onEvent}) : assert(Activsy.isInitialized, () { throw FlutterError( 'activsy no initialized.\nMust call the Activsy.initialize() before the ActivsyWidget'); - }()); + }()), + super(key: key); /// [_onEvent] notify when has event void _onEvent(PointerEvent event) { From 867d0035450e09077b3ee429ba2a8608870b296f Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:29:53 +0100 Subject: [PATCH 07/12] write update topics --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e23b9..6c38086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,3 +9,11 @@ * Intercept events * Change in the name of methods * Check active monitoring + +## 1.0.2 +* Fix initialize monitoring +* Fix ```stop``` monitoring +* Fix ```start``` monitoring +* Fix ```reset``` monitoring +* Rename methods +* Other fixes From 809788532593e03ba0eefc4746af6e3a08743776 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:30:10 +0100 Subject: [PATCH 08/12] update sdk versions --- example/pubspec.lock | 2 +- example/pubspec.yaml | 2 +- pubspec.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 8f30eb0..58aaf10 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "1.0.2" async: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 8475837..38f0d11 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.16.2 <3.0.0" + sdk: '>=2.18.2 <3.0.0' # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/pubspec.yaml b/pubspec.yaml index 831a7e7..5a94513 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,12 +1,12 @@ name: activsy description: reacts when there are no user activities in your application -version: 1.0.1 +version: 1.0.2 homepage: https://github.com/EdvaldoMartins/activsy repository: https://github.com/EdvaldoMartins/activsy issue_tracker: https://github.com/EdvaldoMartins/activsy/issues environment: - sdk: ">=2.16.2 <3.0.0" + sdk: '>=2.18.2 <4.0.0' flutter: ">=1.17.0" dependencies: From a43b1b23d579633b9908a17061c804d71bdbd3b5 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:39:56 +0100 Subject: [PATCH 09/12] update doc --- README.md | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 5ddd93b..26e42bf 100644 --- a/README.md +++ b/README.md @@ -13,20 +13,10 @@ dependencies: ```dart void main() { - Activsy.config(seconds: 10, noActivity: () async { + Activsy.initialize(waiTime: 10, onTimeOut: () { /// perform operation /// call the start to continue monitoring - }); - runApp(const MyApp()); -} - -or - -void main() { - Activsy.config(seconds: 10, noActivity: () async { - /// perform operation - /// call the start to continue monitoring - }).init(); + }); runApp(const MyApp()); } ``` @@ -53,19 +43,18 @@ ActivsyWidget( ) ``` -After the ```onActivity``` method call the monitoring is terminated +After the ```onTimeOut``` method call the monitoring is terminated -| Functions And Attributes | Description | -|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| -| init | Starts monitoring after setting up. Uses the method `start()` | -| start | To monitor user interaction with the application just call `Activsy.start()`. Can be called multiple times but if monitoring is already active nothing happens | -| cancel | Ends monitoring `Activsy.reset()`. Can be called multiple times | -| reset | Restart monitoring `Activsy.reset()`, he calls `start()` and then `cancel()`. This method also to modify the waiting time: `Activsy.reset(seconds: 60)` | -| trigger | Triggers the onActivity method at any point in the application `Activsy.trigger()`. There are several reasons to trigger the noActivity method before the stipulated timer | -| isInitialized | true returns if the setup was made | -| isActive | true returns if monitoring this active | +| Functions And Attributes | Description | +|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| start | To monitor user interaction with the application just call `Activsy.start()`. Can be called multiple times but if monitoring is already active nothing happens | +| stop | Ends monitoring `Activsy.reset()`. Can be called multiple times | +| reset | Restart monitoring `Activsy.reset()`, he calls `start()` and then `stop()`. This method also to modify the waiting time: `Activsy.updateTime(waiTime: 60)` | +| forceTimeOut | Triggers the onTimeOut method at any point in the application `Activsy.forceTimeOut()`. There are several reasons to trigger the noActivity method before the stipulated timer | +| isInitialized | true returns if the setup was made | +| isActive | true returns if monitoring this active | **Note**: call the functions after the **config** method otherwise you will throw an exception From 1afe36c49ff4f855ddfc78b6faa574649d2a29c6 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:40:11 +0100 Subject: [PATCH 10/12] remove time limitation --- lib/src/activsy.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/activsy.dart b/lib/src/activsy.dart index a1f6d93..f09d7a3 100644 --- a/lib/src/activsy.dart +++ b/lib/src/activsy.dart @@ -22,7 +22,7 @@ class Activsy { /// all methods threw exception if they are called before this method factory Activsy.initialize( {required int waiTime, required Function() onTimeOut}) { - assert(waiTime <= 30, "Standby time should not be more than 30 seconds"); + // assert(waiTime <= 30, "Standby time should not be more than 30 seconds"); _initialized = true; _instance = _instance ?? Activsy._(); @@ -76,7 +76,7 @@ class Activsy { throw Exception('this function to be called after the initialize method'); } - assert(waiTime <= 30, "Standby time should not be more than 30 seconds"); + // assert(waiTime <= 30, "Standby time should not be more than 30 seconds"); var timer = _instance!._timer; From e5dcb5aac12373d1e6b109c45810cfaea7f4b3d3 Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:41:33 +0100 Subject: [PATCH 11/12] update --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c38086..f24417d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,3 +17,8 @@ * Fix ```reset``` monitoring * Rename methods * Other fixes + +## 1.0.3 +* Remove time limitation +* Update example +* Other fixes diff --git a/pubspec.yaml b/pubspec.yaml index 5a94513..f061358 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: activsy description: reacts when there are no user activities in your application -version: 1.0.2 +version: 1.0.3 homepage: https://github.com/EdvaldoMartins/activsy repository: https://github.com/EdvaldoMartins/activsy issue_tracker: https://github.com/EdvaldoMartins/activsy/issues From e28965a41eeaaaeba7025c6060b36c1f2ca2f51d Mon Sep 17 00:00:00 2001 From: Edvaldo Martins Date: Mon, 21 Aug 2023 10:44:21 +0100 Subject: [PATCH 12/12] update version lib --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26e42bf..f790274 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ reacts when there are no user activities in your application ```yaml dependencies: - activsy: ^1.0.1 + activsy: ^1.0.3 ``` # Usage