name27 / flutter

0 stars 0 forks source link

youtube music app UI - shape, theme, alignment, mainAxisSize #33

Open name27 opened 1 year ago

name27 commented 1 year ago

image

Main.dart

// ignore_for_file: prefer_const_constructors
// ignore_for_file: prefer_const_literals_to_create_immutables
import 'package:flutter/material.dart';
import 'package:new_project_youtube_music_app/MusicTile.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false, //debug 배너 제거
      home: Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          leading: Icon(Icons.arrow_back_ios),
          title: Text('아워리스트'),
          backgroundColor: Colors.transparent,
          foregroundColor: Colors.white,
          elevation: 0,
          actions: [
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Icon(Icons.desktop_windows_rounded),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Icon(Icons.search),
            )
          ],
        ),
        body: ListView(
          children: [
            MusicTile(
              imgUrl: ('assets/music_come_with_me.png'),
              title: ('Come with me'),
              name: ('Surfaces 및 salem ilese'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_good_day.png'),
              title: ('Good day'),
              name: ('Surfaces'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_honesty.png'),
              title: ('Honesty'),
              name: ('Pink Sweat\$'),
              playTime: ('3:09'),
            ),
            MusicTile(
              imgUrl: ('assets/music_i_wish_i_missed_my_ex.png'),
              title: ('I Wish I Missed My Ex'),
              name: ('마할리아 버크마'),
              playTime: ('3:24'),
            ),
            MusicTile(
              imgUrl: ('assets/music_plastic_plants.png'),
              title: ('Plastic Plants'),
              name: ('마할리아 버크마'),
              playTime: ('3:20'),
            ),
            MusicTile(
              imgUrl: ('assets/music_sucker_for_you.png'),
              title: ('Sucker for you'),
              name: ('맷 테리'),
              playTime: ('3:24'),
            ),
            MusicTile(
              imgUrl: ('assets/music_summer_is_for_falling_in_love.png'),
              title: ('Summer is for falling in love'),
              name: ('Sarah Kang & Eye Love Brandon'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_these_days.png'),
              title: ('These days(feat. Jess Glynne, Macklemore & Dan Caplen)'),
              name: ('Rudimental'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_you_make_me.png'),
              title: ('You Make Me'),
              name: ('DAY6'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_zombie_pop.png'),
              title: ('Zombie Pop'),
              name: ('DRP IAN'),
              playTime: ('3:09'),
            ),
          ],
        ),
        bottomSheet: Container(
          color: Colors.grey[850],
          height: 80,
          child: ListTile(
            leading: Image.asset(
              'assets/music_you_make_me.png',
              width: 55,
              height: 55,
            ),
            title: Text(
              'You Make Me',
              style: TextStyle(color: Colors.white),
              maxLines: 2,
            ),
            subtitle: Text(
              'DAY6',
              style: TextStyle(color: Colors.white60),
              maxLines: 1,
            ),
            trailing: Wrap(
              children: [
                Icon(
                  Icons.play_arrow,
                  color: Colors.white,
                ),
                SizedBox(
                  width: 8,
                ),
                Icon(
                  Icons.skip_next,
                  color: Colors.white,
                ),
              ],
            ),
          ),
        ),
        bottomNavigationBar: BottomNavigationBar(
            backgroundColor: Colors.grey[850],
            unselectedItemColor: Colors.white54,
            selectedItemColor: Colors.white,
            currentIndex: 2,
            items: [
              BottomNavigationBarItem(icon: Icon(Icons.home), label: '홈'),
              BottomNavigationBarItem(icon: Icon(Icons.search), label: '둘러보기'),
              BottomNavigationBarItem(
                  icon: Icon(Icons.library_music), label: '보관함'),
            ]),
      ),
    );
  }
}

MusicTile.dart

// ignore_for_file: prefer_const_constructors
// ignore_for_file: prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';

class MusicTile extends StatelessWidget {
  const MusicTile(
      {super.key,
      required this.imgUrl,
      required this.title,
      required this.name,
      required this.playTime});
  final String imgUrl;
  final String title;
  final String name;
  final String playTime;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListTile(
        leading: Image.asset(
          imgUrl,
          width: 55,
          height: 55,
        ),
        title: Text(
          title,
          style: TextStyle(color: Colors.white),
          maxLines: 2,
        ),
        subtitle: Row(
          children: [
            Icon(
              Icons.check_circle,
              color: Colors.white,
              size: 18,
            ),
            SizedBox(
              width: 5,
            ),
            Flexible(
                child: Text(
              name,
              style: TextStyle(color: Colors.white70),
              overflow: TextOverflow.ellipsis,
            )),
            SizedBox(
              width: 5,
            ),
            Icon(
              Icons.circle,
              color: Colors.white70,
              size: 3.5,
            ),
            SizedBox(
              width: 5,
            ),
            Text(
              playTime,
              style: TextStyle(color: Colors.white70),
            )
          ],
        ),
        trailing: Icon(
          Icons.more_vert,
          color: Colors.white,
        ),
      ),
    );
  }
}
name27 commented 1 year ago

image

Main.dart

// ignore_for_file: prefer_const_constructors
// ignore_for_file: prefer_const_literals_to_create_immutables
import 'package:flutter/material.dart';
import 'package:new_project_youtube_music_app/MusicTile.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.from(
        colorScheme: ColorScheme.dark()
        ),
      debugShowCheckedModeBanner: false, //debug 배너 제거
      home: Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          leading: Icon(Icons.arrow_back_ios),
          title: Text('아워리스트'),
          backgroundColor: Colors.transparent,
          elevation: 0,
          actions: [
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Icon(Icons.desktop_windows_rounded),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Icon(Icons.search),
            )
          ],
          shape: Border(
            bottom: BorderSide(color: Colors.grey, width: 1)
          ),
        ),
        body: ListView(
          children: [
            MusicTile(
              imgUrl: ('assets/music_come_with_me.png'),
              title: ('Come with me'),
              name: ('Surfaces 및 salem ilese'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_good_day.png'),
              title: ('Good day'),
              name: ('Surfaces'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_honesty.png'),
              title: ('Honesty'),
              name: ('Pink Sweat\$'),
              playTime: ('3:09'),
            ),
            MusicTile(
              imgUrl: ('assets/music_i_wish_i_missed_my_ex.png'),
              title: ('I Wish I Missed My Ex'),
              name: ('마할리아 버크마'),
              playTime: ('3:24'),
            ),
            MusicTile(
              imgUrl: ('assets/music_plastic_plants.png'),
              title: ('Plastic Plants'),
              name: ('마할리아 버크마'),
              playTime: ('3:20'),
            ),
            MusicTile(
              imgUrl: ('assets/music_sucker_for_you.png'),
              title: ('Sucker for you'),
              name: ('맷 테리'),
              playTime: ('3:24'),
            ),
            MusicTile(
              imgUrl: ('assets/music_summer_is_for_falling_in_love.png'),
              title: ('Summer is for falling in love'),
              name: ('Sarah Kang & Eye Love Brandon'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_these_days.png'),
              title: ('These days(feat. Jess Glynne, Macklemore & Dan Caplen)'),
              name: ('Rudimental'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_you_make_me.png'),
              title: ('You Make Me'),
              name: ('DAY6'),
              playTime: ('3:00'),
            ),
            MusicTile(
              imgUrl: ('assets/music_zombie_pop.png'),
              title: ('Zombie Pop'),
              name: ('DRP IAN'),
              playTime: ('3:09'),
            ),
          ],
        ),
        bottomSheet: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              color: Colors.grey[850],
              height: 80,
              child: ListTile(
                leading: ClipRRect(
                  borderRadius: BorderRadius.circular(12),
                  child: Image.asset(
                    'assets/music_you_make_me.png',
                    width: 55,
                    height: 55,
                  ),
                ),
                title: Text(
                  'You Make Me',
                  maxLines: 2,
                ),
                subtitle: Text(
                  'DAY6',
                  maxLines: 1,
                ),
                trailing: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Icon(
                        Icons.play_arrow,
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Icon(
                        Icons.skip_next,
                      ),
                    ),
                  ]
                ),
                // trailing: Wrap(
                //   children: [
                //     Icon(
                //       Icons.play_arrow,
                //     ),
                //     SizedBox(
                //       width: 8,
                //     ),
                //     Icon(
                //       Icons.skip_next,
                //     ),
                //   ],
                // ),
              ),
            ),
            Container(
              height: 1,
              alignment: Alignment.centerLeft,
              child: Container(
                width: 120,
                color: Colors.white,
              ),
            ),
          ],
        ),
        bottomNavigationBar: BottomNavigationBar(
            selectedItemColor: Colors.white,
            currentIndex: 2,
            items: [
              BottomNavigationBarItem(icon: Icon(Icons.home), label: '홈'),
              BottomNavigationBarItem(icon: Icon(Icons.search), label: '둘러보기'),
              BottomNavigationBarItem(
                  icon: Icon(Icons.library_music), label: '보관함'),
            ]),
      ),
    );
  }
}

MusicTile.dart

// ignore_for_file: prefer_const_constructors
// ignore_for_file: prefer_const_literals_to_create_immutables

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/container.dart';
import 'package:flutter/src/widgets/framework.dart';

class MusicTile extends StatelessWidget {
  const MusicTile(
      {super.key,
      required this.imgUrl,
      required this.title,
      required this.name,
      required this.playTime});
  final String imgUrl;
  final String title;
  final String name;
  final String playTime;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListTile(
        leading: ClipRRect(
          borderRadius: BorderRadius.circular(12),
          child: Image.asset(
            imgUrl,
            width: 55,
            height: 55,
          ),
        ),
        title: Text(
          title,
          maxLines: 2,
        ),
        subtitle: Row(
          children: [
            Icon(
              Icons.check_circle,
              size: 18,
            ),
            SizedBox(
              width: 5,
            ),
            Flexible(
                child: Text(
              name,
              overflow: TextOverflow.ellipsis,
            )),
            SizedBox(
              width: 5,
            ),
            Icon(
              Icons.circle,
              size: 3.5,
            ),
            SizedBox(
              width: 5,
            ),
            Text(
              playTime,
            )
          ],
        ),
        trailing: Icon(
          Icons.more_vert,
          color: Colors.white,
        ),
      ),
    );
  }
}