193 lines
5.6 KiB
Dart
193 lines
5.6 KiB
Dart
part of 'index.dart';
|
|
|
|
abstract interface class DocumentEntity extends Entity {}
|
|
|
|
interface class Category extends DocumentEntity {
|
|
final int id;
|
|
final Color color;
|
|
final String title;
|
|
|
|
Category({
|
|
required this.id,
|
|
required this.color,
|
|
required this.title,
|
|
});
|
|
|
|
factory Category.fromDesc(String desc) {
|
|
return Category(
|
|
id: 0,
|
|
color: Colors.transparent,
|
|
title: desc,
|
|
);
|
|
}
|
|
|
|
static Color isSelected() => Colors.black;
|
|
}
|
|
|
|
interface class Document extends DocumentEntity {
|
|
final int id;
|
|
final String description;
|
|
final String type;
|
|
final Category category;
|
|
final String person;
|
|
final String property;
|
|
String createdAt;
|
|
String updatedAt;
|
|
|
|
Document({
|
|
required this.id,
|
|
required this.description,
|
|
required this.type,
|
|
required this.category,
|
|
required this.person,
|
|
required this.property,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory Document.fromDesc(String desc) => Document(
|
|
id: 0,
|
|
description: desc,
|
|
type: '',
|
|
category: Category.fromDesc(''),
|
|
person: '',
|
|
property: '',
|
|
createdAt: '',
|
|
updatedAt: '',
|
|
);
|
|
}
|
|
|
|
class DocumentItem extends StatelessWidget {
|
|
final Document document;
|
|
|
|
const DocumentItem({Key? key, required this.document}) : super(key: key);
|
|
|
|
Tooltip _buildTooltip(String text, Color color, BuildContext context,
|
|
BoxConstraints constraints) {
|
|
final Color textColor = FlutterFlowTheme.of(context).info;
|
|
|
|
final double boxHeight = MediaQuery.of(context).size.height * 0.02;
|
|
final double boxWidth = MediaQuery.of(context).size.height * 0.1;
|
|
|
|
return Tooltip(
|
|
message: text,
|
|
child: Container(
|
|
width: boxWidth,
|
|
height: boxHeight,
|
|
decoration: BoxDecoration(
|
|
color: color,
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Center(
|
|
child: AutoText(
|
|
text,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
color: textColor,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Color primaryText = FlutterFlowTheme.of(context).primaryText;
|
|
final Color primaryColor = FlutterFlowTheme.of(context).primary;
|
|
|
|
final TextStyle textStyleMajor = TextStyle(
|
|
color: primaryText,
|
|
fontWeight: FontWeight.bold,
|
|
);
|
|
final TextStyle textStyleMinor = TextStyle(
|
|
color: primaryText,
|
|
fontWeight: FontWeight.normal,
|
|
fontStyle: FontStyle.italic,
|
|
);
|
|
final Map<String, dynamic> extra = <String, dynamic>{
|
|
'document': document,
|
|
kTransitionInfoKey: const TransitionInfo(
|
|
hasTransition: true,
|
|
transitionType: PageTransitionType.rightToLeft,
|
|
alignment: Alignment.bottomCenter,
|
|
),
|
|
};
|
|
Future<Object?> onTap() =>
|
|
context.push('/documentViewerScreen', extra: extra);
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.all(8),
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final double boxHeight = constraints.maxHeight > 350
|
|
? MediaQuery.of(context).size.height * 0.07
|
|
: MediaQuery.of(context).size.height * 2;
|
|
|
|
return InkWell(
|
|
onTap: onTap,
|
|
enableFeedback: true,
|
|
overlayColor: WidgetStateProperty.all<Color>(primaryColor),
|
|
borderRadius: BorderRadius.circular(10),
|
|
child: SizedBox(
|
|
height: boxHeight,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
// const SizedBox(width: 10),
|
|
Icon(Icons.description, color: document.category.color),
|
|
// const SizedBox(width: 10),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Tooltip(
|
|
message: document.description,
|
|
child: AutoText(
|
|
document.description,
|
|
style: textStyleMajor,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
AutoText(
|
|
ValidatorUtil.toLocalDateTime(
|
|
'yyyy-MM-dd', document.updatedAt),
|
|
style: textStyleMinor,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
_buildTooltip(
|
|
document.category.title,
|
|
document.category.color,
|
|
context,
|
|
constraints,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// const SizedBox(width: 10),
|
|
Center(
|
|
child: Icon(
|
|
Icons.arrow_right,
|
|
color: primaryText,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|