165 lines
7.1 KiB
Dart
165 lines
7.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'package:sendtrain/database/database.dart' hide ActivityAction;
|
|
import 'package:sendtrain/extensions/string_extensions.dart';
|
|
import 'package:sendtrain/widgets/session_view.dart';
|
|
|
|
class SessionCard extends StatelessWidget {
|
|
final int type;
|
|
final Session session;
|
|
const SessionCard({super.key, this.type = 0, required this.session});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
initializeDateFormatting('en');
|
|
final DateFormat dateFormat = DateFormat('yyyy-MM-dd');
|
|
|
|
Color color = (session.status == SessionStatus.started)
|
|
? Theme.of(context).colorScheme.primaryContainer
|
|
: Theme.of(context).colorScheme.surfaceContainerLow;
|
|
|
|
if (type == 0) {
|
|
return Card(
|
|
color: color,
|
|
margin: const EdgeInsets.fromLTRB(15, 15, 15, 0),
|
|
clipBehavior: Clip.hardEdge,
|
|
child: InkWell(
|
|
splashColor: Colors.deepPurple,
|
|
onTap: () => showGeneralDialog(
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
transitionDuration: const Duration(milliseconds: 220),
|
|
transitionBuilder: (BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
Widget child) {
|
|
Animation<Offset> custom = Tween<Offset>(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: const Offset(0.0, 0.0))
|
|
.animate(animation);
|
|
return SlideTransition(
|
|
position: custom,
|
|
child: Dialog.fullscreen(child: SessionView(session: session)));
|
|
},
|
|
barrierDismissible: true,
|
|
barrierLabel: '',
|
|
context: context,
|
|
pageBuilder: (context, animation1, animation2) {
|
|
return Container();
|
|
}),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
ListTile(
|
|
leading: Padding(
|
|
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
|
child: Container(
|
|
width: 60,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.cover,
|
|
image:
|
|
AssetImage('assets/images/placeholder.jpg')),
|
|
// color: Colors.blue,
|
|
borderRadius:
|
|
BorderRadius.all(Radius.elliptical(10, 10)),
|
|
),
|
|
)),
|
|
title: Text(maxLines: 1, session.title.toTitleCase()),
|
|
subtitle: Text(maxLines: 1, dateFormat.format(session.date as DateTime)),
|
|
trailing: IconButton(
|
|
visualDensity: VisualDensity.compact,
|
|
icon: Icon(Icons.close_rounded),
|
|
onPressed: () {
|
|
showAdaptiveDialog(
|
|
context: context,
|
|
builder: (BuildContext context) => AlertDialog(
|
|
title: const Text('Session Removal'),
|
|
content: const Text(
|
|
'Would you like to permanently remove this session?'),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, 'Cancel'),
|
|
child: const Text('Cancel'),
|
|
),
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, 'OK'),
|
|
child: const Text('OK'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
ListTile(
|
|
contentPadding: const EdgeInsets.fromLTRB(15, 0, 15, 15),
|
|
title: Text(
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontWeight: FontWeight.w300),
|
|
session.content),
|
|
),
|
|
],
|
|
)),
|
|
);
|
|
} else {
|
|
return Card(
|
|
color: color,
|
|
child: InkWell(
|
|
// overlayColor: MaterialStateColor(Colors.deepPurple as int),
|
|
splashColor: Colors.deepPurple,
|
|
borderRadius: const BorderRadius.all(Radius.elliptical(10, 10)),
|
|
onTap: () => showGeneralDialog(
|
|
// barrierColor: Colors.black.withOpacity(0.5),
|
|
transitionDuration: const Duration(milliseconds: 220),
|
|
transitionBuilder: (BuildContext context,
|
|
Animation<double> animation,
|
|
Animation<double> secondaryAnimation,
|
|
Widget child) {
|
|
Animation<Offset> custom = Tween<Offset>(
|
|
begin: const Offset(0.0, 1.0),
|
|
end: const Offset(0.0, 0.0))
|
|
.animate(animation);
|
|
return SlideTransition(
|
|
position: custom,
|
|
child:
|
|
Dialog.fullscreen(child: SessionView(session: session)));
|
|
},
|
|
barrierDismissible: true,
|
|
barrierLabel: '',
|
|
context: context,
|
|
pageBuilder: (context, animation1, animation2) {
|
|
return Container();
|
|
}),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
// color: const Color.fromARGB(47, 0, 0, 0),
|
|
borderRadius: BorderRadius.circular(10),
|
|
image: const DecorationImage(
|
|
colorFilter: ColorFilter.mode(
|
|
Color.fromARGB(220, 41, 39, 39),
|
|
BlendMode.hardLight),
|
|
image: AssetImage('assets/images/placeholder.jpg'),
|
|
fit: BoxFit.cover),
|
|
),
|
|
child: Align(
|
|
alignment: Alignment.center,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
ListTile(
|
|
title: Text(
|
|
maxLines: 3,
|
|
session.title.toTitleCase(),
|
|
textAlign: TextAlign.center),
|
|
subtitle: Text(
|
|
maxLines: 1,
|
|
dateFormat.format(session.date as DateTime),
|
|
textAlign: TextAlign.center),
|
|
),
|
|
])))));
|
|
}
|
|
}
|
|
}
|