나무야2
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:poet/poet_screen.dart';
|
import 'package:poet/poet_screen.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:audioplayers/audioplayers.dart';
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class PoetScreen extends StatefulWidget {
|
class PoetScreen extends StatefulWidget {
|
||||||
final int selectedIndex;
|
final int selectedIndex;
|
||||||
@@ -16,17 +19,30 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
bool _isPlaying = false;
|
bool _isPlaying = false;
|
||||||
Duration _duration = Duration.zero;
|
Duration _duration = Duration.zero;
|
||||||
Duration _position = Duration.zero;
|
Duration _position = Duration.zero;
|
||||||
|
PlayerState? _playerState;
|
||||||
|
late Source _source;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
||||||
|
}
|
||||||
_backgroundImage =
|
_backgroundImage =
|
||||||
'assets/images/00${(widget.selectedIndex + 1).toString()}.jpg';
|
'assets/images/00${(widget.selectedIndex + 1).toString()}.jpg';
|
||||||
|
_source = AssetSource('audio/00${(widget.selectedIndex + 1).toString()}.wav');
|
||||||
|
|
||||||
_audioPlayer.onPlayerStateChanged.listen((state) {
|
_audioPlayer.onPlayerStateChanged.listen((state) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isPlaying = state == PlayerState.playing;
|
_isPlaying = state == PlayerState.playing;
|
||||||
|
_playerState = state;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (state == PlayerState.completed) {
|
||||||
|
_audioPlayer.seek(Duration.zero);
|
||||||
|
setState(() {
|
||||||
|
_position = Duration.zero;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -52,7 +68,7 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
|
|
||||||
Future<void> _setAudio() async {
|
Future<void> _setAudio() async {
|
||||||
try {
|
try {
|
||||||
await _audioPlayer.setSource(AssetSource('audio/music.mp3'));
|
await _audioPlayer.setSource(_source);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle error, e.g., show a snackbar
|
// Handle error, e.g., show a snackbar
|
||||||
print("Error setting audio source: $e");
|
print("Error setting audio source: $e");
|
||||||
@@ -61,6 +77,9 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||||
|
}
|
||||||
_audioPlayer.dispose();
|
_audioPlayer.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -84,81 +103,21 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
|
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
// 상단 바 (뒤로가기, 제목, 새로고침)
|
// 상단 바 (뒤로가기, 제목, 새로고침)
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
_buildCircularButton(Icons.arrow_back, () {
|
||||||
onPressed: () {
|
|
||||||
// 이 버튼을 누르면 이전 화면으로 돌아갑니다.
|
// 이 버튼을 누르면 이전 화면으로 돌아갑니다.
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
}, size: 50, iconSize: 25),
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.black),
|
_buildCircularButton(Icons.refresh, () {}, size: 50, iconSize: 25),
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {},
|
|
||||||
icon: const Icon(Icons.refresh, color: Colors.black),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32),
|
|
||||||
|
|
||||||
// 시 제목
|
|
||||||
const Text(
|
|
||||||
'별을 보며',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
// 시 본문
|
|
||||||
const Text(
|
|
||||||
'내 너무 별을 쳐다보아\n별들은 더럽히지 않았을까.\n\n내 너무 하늘을 쳐다보아\n하늘은 더럽히지 않았을까.\n\n별아, 어찌하라.\n이 세상 무엇을 쳐다보리.\n\nH 흔들리며 흔들리며 걸어가던 거리\n영망으로 술에 취해 쓰러지던 골목에서\n\n바라보며 너 눈물 같은 빛남\n가슴 어지러움 황홀히 헹구어 비치는\n이 찬란함마저 가질 수 없다면\n나는 무엇으로 가난하라.\n\n- 시집 『나의 나무가 너의 나무에게』, 오상사, 1985년',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black87,
|
|
||||||
height: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 48),
|
|
||||||
|
|
||||||
// 추천의 글 박스
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color(0xFFF07B41).withOpacity(0.3),
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
child: const Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'추천의 글',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'밤하늘과 별을 통해 우주와 상호 교감하며 시인으로서 끊임없는\n창작 열정, 내재적 갈등을 보여주는 작품으로 팍팍한 삶의 위로\n가 되는 이성선적 서정의 대표작입니다.',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: Colors.black87,
|
|
||||||
height: 1.4,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(), // Use Spacer to push controls to the bottom
|
|
||||||
|
|
||||||
// 하단 음악 제어
|
// 하단 음악 제어
|
||||||
_buildMusicControls(),
|
_buildMusicControls(),
|
||||||
@@ -206,9 +165,13 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
_buildCircularButton(_isPlaying ? Icons.pause : Icons.play_arrow, () {
|
_buildCircularButton(_isPlaying ? Icons.pause : Icons.play_arrow, () {
|
||||||
if (_isPlaying) {
|
if (_isPlaying) {
|
||||||
_audioPlayer.pause();
|
_audioPlayer.pause();
|
||||||
|
} else {
|
||||||
|
if (_playerState == PlayerState.completed) {
|
||||||
|
_audioPlayer.play(_source);
|
||||||
} else {
|
} else {
|
||||||
_audioPlayer.resume();
|
_audioPlayer.resume();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
_buildCircularButton(Icons.forward_5, () {
|
_buildCircularButton(Icons.forward_5, () {
|
||||||
@@ -234,10 +197,10 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 원형 버튼을 만드는 헬퍼 함수
|
// 원형 버튼을 만드는 헬퍼 함수
|
||||||
Widget _buildCircularButton(IconData icon, VoidCallback onPressed) {
|
Widget _buildCircularButton(IconData icon, VoidCallback onPressed, {double size = 80, double iconSize = 50}) {
|
||||||
return Container(
|
return Container(
|
||||||
width: 50,
|
width: size,
|
||||||
height: 50,
|
height: size,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(0xFFF07B41),
|
color: const Color(0xFFF07B41),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
@@ -246,7 +209,7 @@ class _PoetScreenState extends State<PoetScreen> {
|
|||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
icon: Icon(icon, color: Colors.white),
|
icon: Icon(icon, color: Colors.white),
|
||||||
iconSize: 30,
|
iconSize: iconSize,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user