123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- import 'package:flutter/material.dart';
- import 'package:vitalapp/consts/styles.dart';
- /// 检查小卡片
- class ExamCard extends StatelessWidget {
- const ExamCard({
- super.key,
- this.title,
- required this.content,
- this.clickCard,
- this.titleText,
- this.topPadding = 20,
- this.bottomPadding = 15,
- this.isSelect = false,
- this.color = Colors.white,
- this.required,
- });
- final String? title;
- final Widget content;
- final Widget? titleText;
- final Function? clickCard;
- final double topPadding;
- final double bottomPadding;
- final bool isSelect;
- final Color color;
- final bool? required;
- @override
- Widget build(BuildContext context) {
- return Card(
- elevation: 6,
- shape: RoundedRectangleBorder(
- borderRadius: GlobalStyles.borderRadius,
- ),
- child: Material(
- color: color,
- borderRadius: GlobalStyles.borderRadius,
- child: InkWell(
- borderRadius: GlobalStyles.borderRadius,
- onTap: clickCard != null ? () => clickCard!.call() : null,
- child: _buildTitle(),
- ),
- ),
- );
- }
- Widget _buildTitle() {
- Widget titleContent = const SizedBox();
- if (title?.isNotEmpty ?? false) {
- titleContent = RichText(
- text: TextSpan(
- text: '',
- children: [
- if (required ?? false)
- TextSpan(
- text: "* ",
- style: const TextStyle(color: Colors.red, fontSize: 35),
- ),
- TextSpan(
- text: title ?? '',
- style: TextStyle(
- fontSize: 26,
- color: Colors.black,
- fontFamily: "NotoSansSC",
- fontFamilyFallback: const ["NotoSansSC"],
- ),
- ),
- ],
- ),
- );
- }
- return titleText ??
- Container(
- padding: EdgeInsets.only(
- top: topPadding,
- left: 30,
- bottom: bottomPadding,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- titleContent,
- Expanded(child: content),
- ],
- ),
- );
- }
- }
- /// 检查小卡片
- class ExamCard2 extends StatelessWidget {
- const ExamCard2({
- super.key,
- this.title,
- required this.content,
- this.clickCard,
- this.titleText,
- this.topPadding = 20,
- this.isSelect = false,
- });
- final String? title;
- final Widget content;
- final Widget? titleText;
- final Function? clickCard;
- final double topPadding;
- final bool isSelect;
- @override
- Widget build(BuildContext context) {
- return Card(
- elevation: 6,
- shape: RoundedRectangleBorder(
- borderRadius: GlobalStyles.borderRadius,
- ),
- child: Material(
- color: Colors.white,
- borderRadius: GlobalStyles.borderRadius,
- child: InkWell(
- borderRadius: GlobalStyles.borderRadius,
- onTap: clickCard != null ? () => clickCard!.call() : null,
- child: _buildTitle(),
- ),
- ),
- );
- }
- Widget _buildTitle() {
- // Widget titleContent = const SizedBox();
- // if (title?.isNotEmpty ?? false) {
- // titleContent = Text(
- // title!,
- // style: const TextStyle(fontSize: 26),
- // );
- // }
- return titleText ??
- Container(
- padding: EdgeInsets.only(
- top: topPadding,
- left: 30,
- bottom: 15,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Expanded(child: content),
- ],
- ),
- );
- }
- }
|