2024-01-19 23:44:01 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../themes/stack_colors.dart';
|
|
|
|
import '../utilities/text_styles.dart';
|
|
|
|
import '../utilities/util.dart';
|
|
|
|
import 'conditional_parent.dart';
|
|
|
|
import 'rounded_white_container.dart';
|
2024-01-19 23:44:01 +00:00
|
|
|
|
|
|
|
class DetailItem extends StatelessWidget {
|
|
|
|
const DetailItem({
|
2024-05-02 17:32:02 +00:00
|
|
|
super.key,
|
2024-01-19 23:44:01 +00:00
|
|
|
required this.title,
|
|
|
|
required this.detail,
|
|
|
|
this.button,
|
2024-05-02 17:32:02 +00:00
|
|
|
this.overrideDetailTextColor,
|
2024-01-19 23:44:01 +00:00
|
|
|
this.showEmptyDetail = true,
|
2024-05-02 17:32:02 +00:00
|
|
|
this.horizontal = false,
|
2024-01-19 23:44:01 +00:00
|
|
|
this.disableSelectableText = false,
|
2024-05-02 17:32:02 +00:00
|
|
|
});
|
2024-01-19 23:44:01 +00:00
|
|
|
|
|
|
|
final String title;
|
|
|
|
final String detail;
|
|
|
|
final Widget? button;
|
|
|
|
final bool showEmptyDetail;
|
2024-05-02 17:32:02 +00:00
|
|
|
final bool horizontal;
|
2024-01-19 23:44:01 +00:00
|
|
|
final bool disableSelectableText;
|
2024-05-02 17:32:02 +00:00
|
|
|
final Color? overrideDetailTextColor;
|
2024-01-19 23:44:01 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-05-02 17:32:02 +00:00
|
|
|
final TextStyle detailStyle;
|
|
|
|
if (overrideDetailTextColor != null) {
|
|
|
|
detailStyle = STextStyles.w500_14(context).copyWith(
|
|
|
|
color: overrideDetailTextColor,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
detailStyle = STextStyles.w500_14(context);
|
|
|
|
}
|
|
|
|
|
2024-01-19 23:44:01 +00:00
|
|
|
return ConditionalParent(
|
|
|
|
condition: !Util.isDesktop,
|
|
|
|
builder: (child) => RoundedWhiteContainer(
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
child: ConditionalParent(
|
|
|
|
condition: Util.isDesktop,
|
|
|
|
builder: (child) => Padding(
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
child: child,
|
|
|
|
),
|
2024-05-02 17:32:02 +00:00
|
|
|
child: horizontal
|
|
|
|
? Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
disableSelectableText
|
|
|
|
? Text(
|
|
|
|
title,
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
)
|
|
|
|
: SelectableText(
|
|
|
|
title,
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
2024-01-19 23:44:01 +00:00
|
|
|
),
|
2024-05-02 17:32:02 +00:00
|
|
|
disableSelectableText
|
|
|
|
? Text(
|
|
|
|
detail,
|
|
|
|
style: detailStyle,
|
|
|
|
)
|
|
|
|
: SelectableText(
|
|
|
|
detail,
|
|
|
|
style: detailStyle,
|
2024-01-19 23:44:01 +00:00
|
|
|
),
|
2024-05-02 17:32:02 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
disableSelectableText
|
|
|
|
? Text(
|
|
|
|
title,
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
)
|
|
|
|
: SelectableText(
|
|
|
|
title,
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
|
|
|
button ?? Container(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 5,
|
|
|
|
),
|
|
|
|
detail.isEmpty && showEmptyDetail
|
|
|
|
? disableSelectableText
|
|
|
|
? Text(
|
|
|
|
"$title will appear here",
|
|
|
|
style: STextStyles.w500_14(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textSubtitle3,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: SelectableText(
|
|
|
|
"$title will appear here",
|
|
|
|
style: STextStyles.w500_14(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textSubtitle3,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: disableSelectableText
|
|
|
|
? Text(
|
|
|
|
detail,
|
|
|
|
style: detailStyle,
|
|
|
|
)
|
|
|
|
: SelectableText(
|
|
|
|
detail,
|
|
|
|
style: detailStyle,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-01-19 23:44:01 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|