历史记录
This commit is contained in:
@@ -35,7 +35,6 @@ class _MuyuPageState extends State<MuyuPage> {
|
|||||||
|
|
||||||
List<MeritRecord> _records = [];
|
List<MeritRecord> _records = [];
|
||||||
|
|
||||||
|
|
||||||
final List<AudioOption> audioOptions = const [
|
final List<AudioOption> audioOptions = const [
|
||||||
AudioOption('音效1', 'muyu_1.mp3'),
|
AudioOption('音效1', 'muyu_1.mp3'),
|
||||||
AudioOption('音效2', 'muyu_2.mp3'),
|
AudioOption('音效2', 'muyu_2.mp3'),
|
||||||
@@ -85,7 +84,8 @@ class _MuyuPageState extends State<MuyuPage> {
|
|||||||
image: activeImage,
|
image: activeImage,
|
||||||
onTap: _onKnock,
|
onTap: _onKnock,
|
||||||
),
|
),
|
||||||
if (_cruRecord != null) AnimateText(record: _cruRecord!,)
|
if (_cruRecord != null)
|
||||||
|
AnimateText(record: _cruRecord!)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -95,7 +95,13 @@ class _MuyuPageState extends State<MuyuPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _toHistory() {
|
void _toHistory() {
|
||||||
Navigator.of(context).push(MaterialPageRoute(builder: (_)=>RecordHistory(record: _records.reversed.toList())));
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => RecordHistory(
|
||||||
|
records: _records.reversed.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTapSwitchAudio() {
|
void _onTapSwitchAudio() {
|
||||||
@@ -159,7 +165,7 @@ class _MuyuPageState extends State<MuyuPage> {
|
|||||||
|
|
||||||
String get activeAudio => audioOptions[_activeAudioIndex].src;
|
String get activeAudio => audioOptions[_activeAudioIndex].src;
|
||||||
|
|
||||||
void _onSelectAudio(int value) async{
|
void _onSelectAudio(int value) async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
if (value == _activeAudioIndex) return;
|
if (value == _activeAudioIndex) return;
|
||||||
_activeAudioIndex = value;
|
_activeAudioIndex = value;
|
||||||
|
|||||||
@@ -6,26 +6,35 @@ import 'models/merit_record.dart';
|
|||||||
DateFormat format = DateFormat('yyyy年MM月dd日 HH:mm:ss');
|
DateFormat format = DateFormat('yyyy年MM月dd日 HH:mm:ss');
|
||||||
|
|
||||||
class RecordHistory extends StatelessWidget {
|
class RecordHistory extends StatelessWidget {
|
||||||
final List<MeritRecord> record;
|
final List<MeritRecord> records;
|
||||||
const RecordHistory({Key? key, required this.record}) : super(key: key);
|
|
||||||
|
const RecordHistory({Key? key, required this.records}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar:_buildAppBar(),
|
||||||
iconTheme: const IconThemeData(color: Colors.black),
|
body: Column(
|
||||||
centerTitle: true,
|
children: List.generate(records.length, (index)=>_buildItem(context,index)),
|
||||||
title: const Text('功德记录',style: TextStyle(color: Colors.black,fontSize: 16),),
|
),
|
||||||
elevation: 0,
|
// body: ListView.builder(
|
||||||
backgroundColor: Colors.white,),
|
// itemBuilder: _buildItem, itemCount: records.length,
|
||||||
body: ListView.builder(
|
// ),
|
||||||
itemBuilder: _buildItem,itemCount: record.length,),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget? _buildItem(BuildContext context, int index) {
|
PreferredSizeWidget _buildAppBar() =>
|
||||||
MeritRecord merit = record[index];
|
AppBar(
|
||||||
|
iconTheme: const IconThemeData(color: Colors.black),
|
||||||
|
centerTitle: true,
|
||||||
|
title: const Text(
|
||||||
|
'功德记录', style: TextStyle(color: Colors.black, fontSize: 16),),
|
||||||
|
elevation: 0,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget _buildItem(BuildContext context, int index) {
|
||||||
|
MeritRecord merit = records[index];
|
||||||
String date = format.format(DateTime.fromMillisecondsSinceEpoch(merit.timestamp));
|
String date = format.format(DateTime.fromMillisecondsSinceEpoch(merit.timestamp));
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
@@ -33,8 +42,9 @@ class RecordHistory extends StatelessWidget {
|
|||||||
backgroundImage: AssetImage(merit.image),
|
backgroundImage: AssetImage(merit.image),
|
||||||
),
|
),
|
||||||
title: Text('功德 +${merit.value}'),
|
title: Text('功德 +${merit.value}'),
|
||||||
subtitle: Text('${merit.audio}'),
|
subtitle: Text(merit.audio),
|
||||||
trailing: Text(date,style: const TextStyle(fontSize: 12,color: Colors.grey),),
|
trailing: Text(
|
||||||
|
date, style: const TextStyle(fontSize: 12, color: Colors.grey),),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user