-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,159 additions
and
597 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:background_fetch/background_fetch.dart'; | ||
import 'package:times_up_flutter/widgets/show_logger.dart'; | ||
|
||
@pragma('vm:entry-point') | ||
Future<void> backgroundFetchHeadlessTask(HeadlessTask task) async { | ||
final taskId = task.taskId; | ||
final isTimeout = task.timeout; | ||
|
||
JHLogger.$.e('[BackgroundFetch] Headless event received.'); | ||
|
||
if (isTimeout) { | ||
JHLogger.$.e('[BackgroundFetch] Headless task timed-out: $taskId'); | ||
BackgroundFetch.finish(taskId); | ||
return; | ||
} | ||
} | ||
|
||
Future<void> configureBackgroundFetch() async { | ||
await BackgroundFetch.configure( | ||
BackgroundFetchConfig( | ||
minimumFetchInterval: 1, | ||
stopOnTerminate: false, | ||
enableHeadless: true, | ||
requiresBatteryNotLow: false, | ||
requiresCharging: false, | ||
requiresStorageNotLow: false, | ||
requiresDeviceIdle: false, | ||
requiredNetworkType: NetworkType.NONE, | ||
), | ||
backgroundFetchHeadlessTask, | ||
).then((int status) { | ||
JHLogger.$.e('[BackgroundFetch] Headless task timed-out- $status'); | ||
}).catchError((e) { | ||
JHLogger.$.d("[BackgroundFetch] configure ERROR: $e"); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:times_up_flutter/app/helpers/parsing_extension.dart'; | ||
import 'package:times_up_flutter/models/child_model/child_model.dart'; | ||
|
||
class AppListPage extends StatelessWidget { | ||
const AppListPage({ | ||
required this.childModel, | ||
Key? key, | ||
}) : super(key: key); | ||
|
||
final ChildModel childModel; | ||
|
||
static Future<void> show(BuildContext context, ChildModel model) async { | ||
await Navigator.of(context).push( | ||
PageRouteBuilder<Widget>( | ||
pageBuilder: (context, animation, secondaryAnimation) { | ||
return AppListPage(childModel: model); | ||
}, | ||
transitionsBuilder: (context, animation, secondaryAnimation, child) { | ||
const begin = Offset(1, 0); | ||
const end = Offset.zero; | ||
const curve = Curves.easeInOut; | ||
final tween = | ||
Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); | ||
final offsetAnimation = animation.drive(tween); | ||
return SlideTransition( | ||
position: offsetAnimation, | ||
child: child, | ||
); | ||
}, | ||
transitionDuration: const Duration(milliseconds: 400), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final themeData = Theme.of(context); | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
leading: IconButton( | ||
icon: const Icon(Icons.chevron_left), | ||
onPressed: () => Navigator.of(context).pop(), | ||
), | ||
elevation: 0, | ||
backgroundColor: themeData.scaffoldBackgroundColor, | ||
), | ||
body: ListView.builder( | ||
physics: const BouncingScrollPhysics( | ||
decelerationRate: ScrollDecelerationRate.fast), | ||
itemCount: childModel.appsUsageModel.length, | ||
itemBuilder: (context, index) { | ||
return Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
ListTile( | ||
leading: childModel.appsUsageModel[index].appIcon != null | ||
? Image.memory( | ||
childModel.appsUsageModel[index].appIcon!, | ||
height: 35, | ||
) | ||
: const Icon(Icons.android), | ||
title: Text( | ||
childModel.appsUsageModel[index].appName, | ||
style: TextStyle( | ||
fontSize: 15, | ||
fontWeight: FontWeight.bold, | ||
color: themeData.dividerColor, | ||
), | ||
), | ||
trailing: Text( | ||
childModel.appsUsageModel[index].usage.toString().t(), | ||
style: TextStyle( | ||
fontSize: 14, | ||
fontWeight: FontWeight.w600, | ||
color: themeData.dividerColor, | ||
), | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.