-
Notifications
You must be signed in to change notification settings - Fork 3
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
17 changed files
with
825 additions
and
193 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
258 changes: 258 additions & 0 deletions
258
notiflut_daemon/lib/src/native/bridge_definitions.freezed.dart
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
import 'package:flutter/material.dart' hide BoxDecoration, BoxShadow; | ||
import 'package:flutter_inset_box_shadow/flutter_inset_box_shadow.dart'; | ||
import 'package:notiflut_land/src/widgets/notification.dart'; | ||
import '../native.dart' as nati; | ||
import '../native/bridge_definitions.dart' as nati; | ||
|
||
class NotificationCategory extends StatefulWidget { | ||
final String appName; | ||
final List<NotificationTile> children; | ||
final bool defaultState; | ||
|
||
const NotificationCategory({ | ||
required this.appName, | ||
this.defaultState = false, | ||
this.children = const [], | ||
super.key, | ||
}); | ||
|
||
@override | ||
State<NotificationCategory> createState() => _NotificationCategoryState(); | ||
} | ||
|
||
class _NotificationCategoryState extends State<NotificationCategory> { | ||
bool _open = false; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_open = widget.defaultState; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.fromLTRB(10, 0, 0, 0), | ||
child: Text( | ||
widget.appName.capitalize(), | ||
style: const TextStyle(color: Colors.white), | ||
), | ||
), | ||
if (widget.children.length > 1) | ||
Row( | ||
children: [ | ||
ElevatedButton( | ||
style: const ButtonStyle( | ||
backgroundColor: | ||
MaterialStatePropertyAll(Color(0xBBE0E0E0)), | ||
shape: MaterialStatePropertyAll( | ||
RoundedRectangleBorder( | ||
borderRadius: | ||
BorderRadius.all(Radius.circular(10))), | ||
)), | ||
onPressed: () { | ||
setState(() { | ||
_open = !_open; | ||
}); | ||
}, | ||
child: Text(_open ? "Show less" : "See more", | ||
style: const TextStyle(color: Colors.black)), | ||
), | ||
SizedBox(width: 20), | ||
CircleAvatar( | ||
radius: 15, | ||
backgroundColor: const Color(0xBBE0E0E0), | ||
child: IconButton( | ||
iconSize: 15, | ||
icon: const Icon( | ||
Icons.close, | ||
color: Colors.black, | ||
), | ||
onPressed: () { | ||
nati.api.sendDaemonAction( | ||
action: nati.DaemonAction.flutterCloseAllApp( | ||
widget.appName)); | ||
}, | ||
), | ||
), | ||
SizedBox(width: 5), | ||
], | ||
), | ||
], | ||
), | ||
AnimatedCrossFade( | ||
firstChild: widget.children.isEmpty | ||
? NotificationTile.empty() | ||
: NotificationTileStack(widget.children[0]), | ||
secondChild: Column(children: widget.children), | ||
crossFadeState: widget.children.length == 1 | ||
? CrossFadeState.showSecond | ||
: _open | ||
? CrossFadeState.showSecond | ||
: CrossFadeState.showFirst, | ||
duration: const Duration(milliseconds: 300), | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class NotificationTileStack extends StatelessWidget { | ||
final NotificationTile tile; | ||
const NotificationTileStack(this.tile, {super.key}); | ||
|
||
Widget buildFakeNotificationBottomTile(BuildContext context, int lvl) { | ||
return Container( | ||
margin: EdgeInsets.fromLTRB(10 + lvl * 10, 0, 10 + lvl * 10, 0), | ||
decoration: const BoxDecoration( | ||
color: Color(0xBBE0E0E0), | ||
borderRadius: BorderRadius.only( | ||
bottomLeft: Radius.circular(30), | ||
bottomRight: Radius.circular(30), | ||
), | ||
boxShadow: [ | ||
BoxShadow( | ||
color: Colors.black54, | ||
blurRadius: 1.0, | ||
offset: Offset(0.0, 0.75), | ||
inset: true, | ||
) | ||
], | ||
), | ||
height: 10, | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
Stack( | ||
children: [ | ||
tile, | ||
Column( | ||
children: [ | ||
Visibility( | ||
visible: false, | ||
maintainSize: true, | ||
maintainAnimation: true, | ||
maintainState: true, | ||
child: NotificationTile( | ||
tile.id, | ||
tile.appName, | ||
tile.title, | ||
tile.body, | ||
actions: tile.actions, | ||
margin: const EdgeInsets.fromLTRB(4, 4, 4, 0), | ||
), | ||
), | ||
buildFakeNotificationBottomTile(context, 1), | ||
buildFakeNotificationBottomTile(context, 2), | ||
], | ||
) | ||
], | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
extension StringExtension on String { | ||
String capitalize() { | ||
return "${this[0].toUpperCase()}${substring(1)}"; | ||
} | ||
} |
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
Oops, something went wrong.