Pull the basic card types out into their own file for possible reuse.
This commit is contained in:
parent
e7dc369c4f
commit
62379f54b0
@ -4,6 +4,7 @@ import 'package:flutter_expense_tracker/models/item_type.dart';
|
||||
|
||||
// Local
|
||||
import '/db.dart';
|
||||
import '/widgets/cards.dart';
|
||||
import '/models/tracked_item.dart';
|
||||
|
||||
/// TODO:
|
||||
@ -109,28 +110,6 @@ class _ProjectionPageState extends State<ProjectionPage> {
|
||||
}
|
||||
}
|
||||
|
||||
class TitleCard extends StatelessWidget {
|
||||
const TitleCard({
|
||||
super.key,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SummaryCardForTotals extends StatelessWidget {
|
||||
const SummaryCardForTotals({
|
||||
super.key,
|
||||
@ -229,72 +208,3 @@ class SummaryCardForTotals extends StatelessWidget {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class SummaryCard extends StatefulWidget {
|
||||
const SummaryCard({
|
||||
super.key,
|
||||
required this.name,
|
||||
required this.leftText,
|
||||
required this.middleText,
|
||||
required this.rightText,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String leftText;
|
||||
final String middleText;
|
||||
final String rightText;
|
||||
|
||||
@override
|
||||
State<SummaryCard> createState() => _SummaryCardState();
|
||||
}
|
||||
|
||||
class _SummaryCardState extends State<SummaryCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: Theme.of(context).cardColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Card(
|
||||
color: Theme.of(context).highlightColor,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
widget.name,
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(
|
||||
flex: 3,
|
||||
),
|
||||
Text(
|
||||
widget.leftText,
|
||||
),
|
||||
Spacer(
|
||||
flex: 1,
|
||||
),
|
||||
Text(
|
||||
widget.middleText,
|
||||
),
|
||||
Spacer(
|
||||
flex: 1,
|
||||
),
|
||||
Text(
|
||||
widget.rightText,
|
||||
),
|
||||
Spacer(
|
||||
flex: 3,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
87
lib/widgets/cards.dart
Normal file
87
lib/widgets/cards.dart
Normal file
@ -0,0 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TitleCard extends StatelessWidget {
|
||||
const TitleCard({
|
||||
super.key,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SummaryCard extends StatelessWidget {
|
||||
const SummaryCard({
|
||||
super.key,
|
||||
required this.name,
|
||||
required this.leftText,
|
||||
required this.middleText,
|
||||
required this.rightText,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String leftText;
|
||||
final String middleText;
|
||||
final String rightText;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: Theme.of(context).cardColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Card(
|
||||
color: Theme.of(context).highlightColor,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(
|
||||
flex: 3,
|
||||
),
|
||||
Text(
|
||||
leftText,
|
||||
),
|
||||
Spacer(
|
||||
flex: 1,
|
||||
),
|
||||
Text(
|
||||
middleText,
|
||||
),
|
||||
Spacer(
|
||||
flex: 1,
|
||||
),
|
||||
Text(
|
||||
rightText,
|
||||
),
|
||||
Spacer(
|
||||
flex: 3,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user