178 lines
5.1 KiB
Dart
178 lines
5.1 KiB
Dart
part of 'index.dart';
|
|
|
|
interface class Document extends Archive {
|
|
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: '',
|
|
);
|
|
}
|
|
|
|
// ignore: must_be_immutable
|
|
class DocumentItem extends StatelessComponent {
|
|
final Document document;
|
|
void Function(Document, BuildContext) onPressed;
|
|
|
|
DocumentItem({
|
|
super.key,
|
|
required this.document,
|
|
required this.onPressed,
|
|
});
|
|
|
|
Tooltip _buildTooltip(String text, Color color, BuildContext context,
|
|
BoxConstraints constraints) {
|
|
final Color textColor = FlutterFlowTheme.of(context).info;
|
|
|
|
final area = (MediaQuery.of(context).size.height +
|
|
MediaQuery.of(context).size.width) /
|
|
2;
|
|
|
|
final double boxHeight = area * 0.033;
|
|
final double boxWidth = area * 0.19;
|
|
|
|
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,
|
|
);
|
|
|
|
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: () => onPressed(document, context),
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
DocumentItem copyWith({
|
|
Document? document,
|
|
}) {
|
|
return DocumentItem(
|
|
document: document ?? this.document,
|
|
onPressed: onPressed,
|
|
);
|
|
}
|
|
}
|