From be04006e2a120f9f66ce416b67a32a2f96a7a4ea Mon Sep 17 00:00:00 2001 From: toly <1981462002@qq.com> Date: Sat, 29 Apr 2023 10:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/muyu/count_panel.dart | 56 +++++++++++++++++++++++++++++++++++++++ lib/muyu/muyu_page.dart | 56 +++++++++------------------------------ 2 files changed, 69 insertions(+), 43 deletions(-) create mode 100644 lib/muyu/count_panel.dart diff --git a/lib/muyu/count_panel.dart b/lib/muyu/count_panel.dart new file mode 100644 index 0000000..8512e9d --- /dev/null +++ b/lib/muyu/count_panel.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; + +class CountPanel extends StatelessWidget { + final int count; + final VoidCallback onTapSwitchAudio; + final VoidCallback onTapSwitchImage; + + const CountPanel({ + super.key, + required this.count, + required this.onTapSwitchAudio, + required this.onTapSwitchImage, + }); + + @override + Widget build(BuildContext context) { + final ButtonStyle style = ElevatedButton.styleFrom( + minimumSize: const Size(36, 36), + padding: EdgeInsets.zero, + backgroundColor: Colors.green, + elevation: 0, + ); + return Stack( + children: [ + Center( + child: Text( + '功德数: $count', + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), + ), + ), + Positioned( + right: 10, + top: 10, + child: Wrap( + spacing: 8, + direction: Axis.vertical, + children: [ + ElevatedButton( + style: style, + onPressed: onTapSwitchAudio, + child: Icon(Icons.music_note_outlined), + ), + ElevatedButton( + style: style, + onPressed: onTapSwitchImage, + child: Icon(Icons.image), + ) + ], + )), + ], + ); + } +} diff --git a/lib/muyu/muyu_page.dart b/lib/muyu/muyu_page.dart index 0fffb2b..9c5f016 100644 --- a/lib/muyu/muyu_page.dart +++ b/lib/muyu/muyu_page.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'count_panel.dart'; + class MuyuPage extends StatefulWidget { const MuyuPage({Key? key}) : super(key: key); @@ -27,7 +29,13 @@ class _MuyuPageState extends State { ), body: Column( children: [ - Expanded(child: _buildTopContent()), + Expanded( + child: CountPanel( + count: 0, + onTapSwitchAudio: _onTapSwitchAudio, + onTapSwitchImage: _onTapSwitchImage, + ), + ), Expanded(child: _buildImage()), ], ), @@ -36,48 +44,6 @@ class _MuyuPageState extends State { void _toHistory() {} - Widget _buildTopContent() { - final ButtonStyle style = ElevatedButton.styleFrom( - minimumSize: const Size(36, 36), - padding: EdgeInsets.zero, - backgroundColor: Colors.green, - elevation: 0, - ); - - return Stack( - children: [ - Center( - child: Text( - '功德数: 0', - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, - ), - ), - ), - Positioned( - right: 10, - top: 10, - child: Wrap( - spacing: 8, - direction: Axis.vertical, - children: [ - ElevatedButton( - style: style, - onPressed: () {}, - child: Icon(Icons.music_note_outlined), - ), - ElevatedButton( - style: style, - onPressed: () {}, - child: Icon(Icons.image), - ) - ], - )), - ], - ); - } - Widget _buildImage() { return Center( child: Image.asset( @@ -85,4 +51,8 @@ class _MuyuPageState extends State { height: 200, )); } + + void _onTapSwitchAudio() {} + + void _onTapSwitchImage() {} }