Files
zh-chat-flutter/lib/views/home/widgets/action_item.dart
2022-10-31 16:12:06 +08:00

105 lines
2.9 KiB
Dart

import 'package:chat/configs/app_colors.dart';
import 'package:flutter/material.dart';
class ActionItem extends StatelessWidget {
final String title;
final String? extend;
final Widget? rightWidget;
final String? bottom;
final VoidCallback? onTap;
final bool isFirst;
final bool isLast;
final double indent;
const ActionItem(
this.title, {
this.extend,
this.rightWidget,
this.bottom,
this.onTap,
this.isFirst = false,
this.isLast = false,
this.indent = 16,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
onTap?.call();
},
child: Column(
children: [
if (isFirst)
const Divider(
height: 0.4,
color: AppColors.border,
),
Container(
padding: const EdgeInsets.all(16),
decoration: const BoxDecoration(
color: AppColors.white,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: const TextStyle(
fontSize: 16,
),
),
Expanded(child: Container()),
if (extend != null)
Text(
extend!,
style: const TextStyle(
color: AppColors.unactive,
),
),
rightWidget ??
const Icon(
Icons.arrow_forward_ios,
size: 14,
color: AppColors.unactive,
),
],
),
if (bottom != null && bottom!.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
bottom!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: AppColors.unactive,
fontSize: 12,
),
),
),
],
),
),
if (isLast)
const Divider(
height: 0,
color: AppColors.border,
),
if (!isLast)
Divider(
height: 0,
color: AppColors.border,
indent: indent,
),
],
),
);
}
}