From 456a7fae65185c3e457ccfab0e5e824c8190535d Mon Sep 17 00:00:00 2001 From: taliafr <78625077+taliafr@users.noreply.github.com> Date: Sat, 14 Jan 2023 15:00:02 -0600 Subject: [PATCH 01/11] some switches for group vs indiv. --- lib/screen/profile_screen.dart | 47 +++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/lib/screen/profile_screen.dart b/lib/screen/profile_screen.dart index 21c6537..96fbcb6 100644 --- a/lib/screen/profile_screen.dart +++ b/lib/screen/profile_screen.dart @@ -5,6 +5,7 @@ import '../widgets/my_navigation_bar.dart'; import '../widgets/outlined_button.dart'; class ProfileScreen extends StatelessWidget { + final bool group = false; const ProfileScreen({Key? key}) : super(key: key); @override @@ -68,20 +69,53 @@ class ProfileScreen extends StatelessWidget { onPressed: () => {}, toggle: false, ), - const SizedBox( - width: 25, + SizedBox( + width: group ? 25 : 0, ), - TunedInOutlinedButton( + group ? TunedInOutlinedButton( text: "Join", onPressed: () => {}, toggle: true, - ), + ) : const SizedBox.shrink(), ], )), const SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: !group ? [ + // Text( + // "200", + // style: + // Theme.of(context).textTheme.displaySmall?.copyWith( + // fontWeight: FontWeight.w600, + // ), + // ), + // Text(" Followers", + // style: Theme.of(context).textTheme.displaySmall), + // const SizedBox(width: 25, height: 2), + // Text( + // "200", + // style: + // Theme.of(context).textTheme.displaySmall?.copyWith( + // fontWeight: FontWeight.w600, + // ), + // ), + // Text(" Following", + // style: Theme.of(context).textTheme.displaySmall) + + const SizedBox( + width: 100, + child: Text("Followers\n 200", textAlign: TextAlign.center), + + ), + const SizedBox(width: 25, height: 2), + const SizedBox( + width: 100, + child: Text("Following\n 200", textAlign: TextAlign.center), + + ), + + ] : [ Text( "200", style: @@ -90,7 +124,8 @@ class ProfileScreen extends StatelessWidget { ), ), Text(" Followers", - style: Theme.of(context).textTheme.displaySmall) + style: Theme.of(context).textTheme.displaySmall), + const SizedBox(width: 25, height: 2) ], ), Text( From 6fb359998e4d9e9231a518666b68bc0af282b323 Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 21 Jan 2023 13:57:34 -0600 Subject: [PATCH 02/11] changes in PR --- lib/main.dart | 20 ++++--- lib/screen/profile_screen.dart | 104 +++++++++++++++++---------------- 2 files changed, 66 insertions(+), 58 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d25a031..5aa1330 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:rice_music_sharing/screen/group_and_profile_screen.dart'; import 'themes/themes.dart'; import 'widgets/my_navigation_bar.dart'; @@ -12,17 +13,18 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( + home: ProfileScreen(true), theme: Themes.darkTheme, title: 'Welcome to TunedIn', - home: Scaffold( - bottomNavigationBar: const MyNavigationBar(), - appBar: AppBar( - title: const Text('Welcome to TunedIn'), - ), - body: const Center( - child: Text('Hello World'), - ), - ), + // home: Scaffold( + // bottomNavigationBar: const MyNavigationBar(), + // appBar: AppBar( + // title: const Text('Welcome to TunedIn'), + // ), + // body: const Center( + // child: Text('Hello World'), + // ), + // ), ); } } diff --git a/lib/screen/profile_screen.dart b/lib/screen/profile_screen.dart index 96fbcb6..2cb4b05 100644 --- a/lib/screen/profile_screen.dart +++ b/lib/screen/profile_screen.dart @@ -72,61 +72,67 @@ class ProfileScreen extends StatelessWidget { SizedBox( width: group ? 25 : 0, ), - group ? TunedInOutlinedButton( - text: "Join", - onPressed: () => {}, - toggle: true, - ) : const SizedBox.shrink(), + group + ? TunedInOutlinedButton( + text: "Join", + onPressed: () => {}, + toggle: true, + ) + : const SizedBox.shrink(), ], )), const SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.center, - children: !group ? [ - // Text( - // "200", - // style: - // Theme.of(context).textTheme.displaySmall?.copyWith( - // fontWeight: FontWeight.w600, - // ), - // ), - // Text(" Followers", - // style: Theme.of(context).textTheme.displaySmall), - // const SizedBox(width: 25, height: 2), - // Text( - // "200", - // style: - // Theme.of(context).textTheme.displaySmall?.copyWith( - // fontWeight: FontWeight.w600, - // ), - // ), - // Text(" Following", - // style: Theme.of(context).textTheme.displaySmall) - - const SizedBox( - width: 100, - child: Text("Followers\n 200", textAlign: TextAlign.center), - - ), - const SizedBox(width: 25, height: 2), - const SizedBox( - width: 100, - child: Text("Following\n 200", textAlign: TextAlign.center), + children: !group + ? [ + // Text( + // "200", + // style: + // Theme.of(context).textTheme.displaySmall?.copyWith( + // fontWeight: FontWeight.w600, + // ), + // ), + // Text(" Followers", + // style: Theme.of(context).textTheme.displaySmall), + // const SizedBox(width: 25, height: 2), + // Text( + // "200", + // style: + // Theme.of(context).textTheme.displaySmall?.copyWith( + // fontWeight: FontWeight.w600, + // ), + // ), + // Text(" Following", + // style: Theme.of(context).textTheme.displaySmall) - ), - - ] : [ - Text( - "200", - style: - Theme.of(context).textTheme.displaySmall?.copyWith( - fontWeight: FontWeight.w600, - ), - ), - Text(" Followers", - style: Theme.of(context).textTheme.displaySmall), - const SizedBox(width: 25, height: 2) - ], + const SizedBox( + width: 100, + child: Text("Followers\n 200", + textAlign: TextAlign.center), + ), + const SizedBox(width: 25, height: 2), + const SizedBox( + width: 100, + child: Text("Following\n 200", + textAlign: TextAlign.center), + ), + ] + : [ + Text( + "200", + style: Theme.of(context) + .textTheme + .displaySmall + ?.copyWith( + fontWeight: FontWeight.w600, + ), + ), + Text(" Followers", + style: + Theme.of(context).textTheme.displaySmall), + const SizedBox(width: 25, height: 2) + ], ), Text( "Playlists: 4", From 50a6e8f54890528ea478d54783c516db1cbbb15b Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 21 Jan 2023 14:04:36 -0600 Subject: [PATCH 03/11] profile screen changes --- lib/screen/group_and_profile_screen.dart | 217 +++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 lib/screen/group_and_profile_screen.dart diff --git a/lib/screen/group_and_profile_screen.dart b/lib/screen/group_and_profile_screen.dart new file mode 100644 index 0000000..3b7ad3f --- /dev/null +++ b/lib/screen/group_and_profile_screen.dart @@ -0,0 +1,217 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +import '../widgets/my_navigation_bar.dart'; +import '../widgets/outlined_button.dart'; + +class ProfileScreen extends StatelessWidget { + ProfileScreen(this.isGroup); + + final bool isGroup; + @override + Widget build(BuildContext context) { + return Scaffold( + bottomNavigationBar: const MyNavigationBar(), + backgroundColor: Theme.of(context).colorScheme.background, + body: Stack(children: [ + SvgPicture.asset( + 'Gradient.svg', + alignment: Alignment.topCenter, + width: MediaQuery.of(context).size.width, + ), + SvgPicture.asset( + 'Vector.svg', + alignment: Alignment.topCenter, + width: MediaQuery.of(context).size.width, + ), + CustomScrollView(slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(20, 85, 20, 20), + sliver: SliverList( + delegate: SliverChildListDelegate([ + CircleAvatar( + foregroundImage: const NetworkImage( + "https://picsum.photos/250?image=9", + ), + radius: 45, + child: Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: Theme.of(context).colorScheme.tertiary, + blurRadius: 40, + blurStyle: BlurStyle.outer, + ), + ], + ), + ), + ), + const SizedBox( + height: 25, + ), + Text( + "Will Rice College", + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox( + height: 25, + ), + Padding( + padding: const EdgeInsets.fromLTRB(30, 0, 30, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + TunedInOutlinedButton( + text: "Follow", + onPressed: () => {}, + toggle: false, + ), + SizedBox( + width: isGroup ? 25 : 0, + ), + isGroup + ? TunedInOutlinedButton( + text: "Join", + onPressed: () => {}, + toggle: true, + ) + : const SizedBox.shrink(), + ], + )), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: !isGroup + ? [ + // Text( + // "200", + // style: + // Theme.of(context).textTheme.displaySmall?.copyWith( + // fontWeight: FontWeight.w600, + // ), + // ), + // Text(" Followers", + // style: Theme.of(context).textTheme.displaySmall), + // const SizedBox(width: 25, height: 2), + // Text( + // "200", + // style: + // Theme.of(context).textTheme.displaySmall?.copyWith( + // fontWeight: FontWeight.w600, + // ), + // ), + // Text(" Following", + // style: Theme.of(context).textTheme.displaySmall) + + const SizedBox( + width: 100, + child: Text("Followers\n 200", + textAlign: TextAlign.center), + ), + const SizedBox(width: 25, height: 2), + const SizedBox( + width: 100, + child: Text("Following\n 200", + textAlign: TextAlign.center), + ), + ] + : [ + Text( + "200", + style: Theme.of(context) + .textTheme + .displaySmall + ?.copyWith( + fontWeight: FontWeight.w600, + ), + ), + Text(" Followers", + style: + Theme.of(context).textTheme.displaySmall), + const SizedBox(width: 25, height: 2) + ], + ), + Text( + "Playlists: 4", + textAlign: TextAlign.left, + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + fontFamily: 'Poppins', + ), + ), + const PlaylistCard(), + const PlaylistCard(), + const PlaylistCard(), + const PlaylistCard(), + const SizedBox(height: 25), + Row(children: const [ + Text( + "Browse all playlists 20", + ), + Spacer(), + Icon(Icons.chevron_right), + ]) + ]), + ), + ) + ]), + ])); + } +} + +class PlaylistCard extends StatelessWidget { + const PlaylistCard({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Card( + child: InkWell( + onTap: () {}, + child: Row( + children: [ + Padding( + padding: const EdgeInsets.all(12), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.0), + child: Image.network( + "https://picsum.photos/250?image=9", + width: 56, + height: 56, + fit: BoxFit.cover, + ), + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Playlist Name", + textAlign: TextAlign.left, + style: Theme.of(context) + .textTheme + .displayMedium + ?.copyWith(color: Colors.white), + ), + const SizedBox( + height: 5, + ), + Text("20 Songs", + textAlign: TextAlign.left, + style: + Theme.of(context).textTheme.displayMedium?.copyWith( + color: const Color(0xFFA1A9BC), + )), + ], + ), + const Spacer(), + const Padding( + padding: EdgeInsets.fromLTRB(0, 0, 10, 0), + child: Icon(Icons.chevron_right), + ), + ], + )), + ); + } +} From b65176bb7327c72ec6c71b8fe1290ae047065289 Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 21 Jan 2023 14:05:48 -0600 Subject: [PATCH 04/11] back to original home --- lib/main.dart | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5aa1330..7ca15ac 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,18 +13,17 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - home: ProfileScreen(true), theme: Themes.darkTheme, title: 'Welcome to TunedIn', - // home: Scaffold( - // bottomNavigationBar: const MyNavigationBar(), - // appBar: AppBar( - // title: const Text('Welcome to TunedIn'), - // ), - // body: const Center( - // child: Text('Hello World'), - // ), - // ), + home: Scaffold( + bottomNavigationBar: const MyNavigationBar(), + appBar: AppBar( + title: const Text('Welcome to TunedIn'), + ), + body: const Center( + child: Text('Hello World'), + ), + ), ); } } From dc6bc3667b7cdc774a703cb1cd77aedc4a28f7fb Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 21 Jan 2023 15:55:16 -0600 Subject: [PATCH 05/11] initial comit for comments screen still broken --- lib/screen/comments_screen.dart | 107 ++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 lib/screen/comments_screen.dart diff --git a/lib/screen/comments_screen.dart b/lib/screen/comments_screen.dart new file mode 100644 index 0000000..ca918a1 --- /dev/null +++ b/lib/screen/comments_screen.dart @@ -0,0 +1,107 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +import '../widgets/my_navigation_bar.dart'; +import '../widgets/outlined_button.dart'; +import '../widgets/single_comment.dart'; + +class CommentsScreen extends StatefulWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + bottomNavigationBar: const MyNavigationBar(), + backgroundColor: Theme.of(context).colorScheme.background, + body: Stack()); + } + + State createState() => _CommentWidgetState(); +} + +class _CommentWidgetState extends State { + @override + Widget build(BuildContext context) { + return Row(); + } + // int _likes = 0; + // bool _isNotLiked = true; + + // void _onLikeTapped() { + // setState(() { + // if (_isNotLiked) { + // _likes = _likes + 1; + // } else { + // _likes = _likes - 1; + // } + // _isNotLiked = !_isNotLiked; + // }); + // } + + // @override + // Widget build(BuildContext context) { + // return Row( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // const CircleAvatar( + // backgroundImage: NetworkImage("https://picsum.photos/250?image=9"), + // radius: 18, + // ), + // const SizedBox( + // width: 10, + // ), + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // children: const [ + // Text("David"), + // SizedBox( + // width: 5, + // ), + // Text("32 min ago"), + // ], + // ), + // const SizedBox( + // height: 5, + // ), + // const Text( + // "I haven't listened to this song in ages.", + // ), + // const SizedBox( + // height: 5, + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // IconButton( + // padding: EdgeInsets.zero, + // constraints: const BoxConstraints(), + // icon: Stack( + // children: [ + // Icon(Icons.favorite, + // color: _isNotLiked ? Colors.transparent : Colors.red), + // Icon(Icons.favorite_border, + // color: _isNotLiked ? Colors.black : Colors.red), + // ], + // ), + // onPressed: () { + // _onLikeTapped(); + // }, + // ), + // const SizedBox( + // width: 5, + // ), + // Text(_likes.toString()), + // const SizedBox( + // width: 10, + // ), + // InkWell( + // child: const Text("Reply"), + // onTap: () {}, + // ), + // ], + // ) + // ], + // ), + // ], + // ); +} From 8cb4d6880450afc7d297e9138a5cd132bb8fd51c Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 21 Jan 2023 16:01:30 -0600 Subject: [PATCH 06/11] compiles --- lib/screen/comments_screen.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/screen/comments_screen.dart b/lib/screen/comments_screen.dart index ca918a1..affeed4 100644 --- a/lib/screen/comments_screen.dart +++ b/lib/screen/comments_screen.dart @@ -14,13 +14,16 @@ class CommentsScreen extends StatefulWidget { body: Stack()); } - State createState() => _CommentWidgetState(); + State createState() => _CommentWidgetState(); } -class _CommentWidgetState extends State { +class _CommentWidgetState extends State { @override Widget build(BuildContext context) { - return Row(); + return Scaffold( + bottomNavigationBar: const MyNavigationBar(), + backgroundColor: Theme.of(context).colorScheme.background, + body: Stack()); } // int _likes = 0; // bool _isNotLiked = true; From c71a79209fbd0e9ce4895ee180fe3060fea0f72e Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 4 Feb 2023 13:36:35 -0600 Subject: [PATCH 07/11] shows single comment --- lib/screen/comments_screen.dart | 182 ++++++++++++++++---------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/lib/screen/comments_screen.dart b/lib/screen/comments_screen.dart index affeed4..7502edd 100644 --- a/lib/screen/comments_screen.dart +++ b/lib/screen/comments_screen.dart @@ -6,105 +6,105 @@ import '../widgets/outlined_button.dart'; import '../widgets/single_comment.dart'; class CommentsScreen extends StatefulWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - bottomNavigationBar: const MyNavigationBar(), - backgroundColor: Theme.of(context).colorScheme.background, - body: Stack()); - } - State createState() => _CommentWidgetState(); } class _CommentWidgetState extends State { + // @override + // Widget build(BuildContext context) { + // return Scaffold( + // bottomNavigationBar: const MyNavigationBar(), + // backgroundColor: Theme.of(context).colorScheme.background, + // body: Stack()); + // } + + int _likes = 0; + bool _isNotLiked = true; + + void _onLikeTapped() { + setState(() { + if (_isNotLiked) { + _likes = _likes + 1; + } else { + _likes = _likes - 1; + } + _isNotLiked = !_isNotLiked; + }); + } + @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: const MyNavigationBar(), backgroundColor: Theme.of(context).colorScheme.background, - body: Stack()); + body: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const CircleAvatar( + backgroundImage: + NetworkImage("https://picsum.photos/250?image=9"), + radius: 18, + ), + const SizedBox( + width: 10, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: const [ + Text("David"), + SizedBox( + width: 5, + ), + Text("32 min ago"), + ], + ), + const SizedBox( + height: 5, + ), + const Text( + "I haven't listened to this song in ages.", + ), + const SizedBox( + height: 5, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + IconButton( + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), + icon: Stack( + children: [ + Icon(Icons.favorite, + color: _isNotLiked + ? Colors.transparent + : Colors.red), + Icon(Icons.favorite_border, + color: _isNotLiked ? Colors.black : Colors.red), + ], + ), + onPressed: () { + _onLikeTapped(); + }, + ), + const SizedBox( + width: 5, + ), + Text(_likes.toString()), + const SizedBox( + width: 10, + ), + InkWell( + child: const Text("Reply"), + onTap: () {}, + ), + ], + ) + ], + ), + ], + )); } - // int _likes = 0; - // bool _isNotLiked = true; - - // void _onLikeTapped() { - // setState(() { - // if (_isNotLiked) { - // _likes = _likes + 1; - // } else { - // _likes = _likes - 1; - // } - // _isNotLiked = !_isNotLiked; - // }); - // } - - // @override - // Widget build(BuildContext context) { - // return Row( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // const CircleAvatar( - // backgroundImage: NetworkImage("https://picsum.photos/250?image=9"), - // radius: 18, - // ), - // const SizedBox( - // width: 10, - // ), - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Row( - // children: const [ - // Text("David"), - // SizedBox( - // width: 5, - // ), - // Text("32 min ago"), - // ], - // ), - // const SizedBox( - // height: 5, - // ), - // const Text( - // "I haven't listened to this song in ages.", - // ), - // const SizedBox( - // height: 5, - // ), - // Row( - // mainAxisAlignment: MainAxisAlignment.start, - // children: [ - // IconButton( - // padding: EdgeInsets.zero, - // constraints: const BoxConstraints(), - // icon: Stack( - // children: [ - // Icon(Icons.favorite, - // color: _isNotLiked ? Colors.transparent : Colors.red), - // Icon(Icons.favorite_border, - // color: _isNotLiked ? Colors.black : Colors.red), - // ], - // ), - // onPressed: () { - // _onLikeTapped(); - // }, - // ), - // const SizedBox( - // width: 5, - // ), - // Text(_likes.toString()), - // const SizedBox( - // width: 10, - // ), - // InkWell( - // child: const Text("Reply"), - // onTap: () {}, - // ), - // ], - // ) - // ], - // ), - // ], - // ); } From d00c4a11577a61289d842210e7881f15e0d2e665 Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 4 Feb 2023 13:46:11 -0600 Subject: [PATCH 08/11] added variables for _commentwidgetstate --- lib/screen/comments_screen.dart | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/screen/comments_screen.dart b/lib/screen/comments_screen.dart index 7502edd..3d759cf 100644 --- a/lib/screen/comments_screen.dart +++ b/lib/screen/comments_screen.dart @@ -6,10 +6,17 @@ import '../widgets/outlined_button.dart'; import '../widgets/single_comment.dart'; class CommentsScreen extends StatefulWidget { - State createState() => _CommentWidgetState(); + @override + State createState() => + _CommentWidgetState("I haven't listened to this song in ages", 0, true); } class _CommentWidgetState extends State { + _CommentWidgetState(this.comment, this.numLikes, this.isNotLiked); + + String comment; + int numLikes; + bool isNotLiked; // if you liked this comment already // @override // Widget build(BuildContext context) { // return Scaffold( @@ -18,17 +25,10 @@ class _CommentWidgetState extends State { // body: Stack()); // } - int _likes = 0; - bool _isNotLiked = true; - void _onLikeTapped() { setState(() { - if (_isNotLiked) { - _likes = _likes + 1; - } else { - _likes = _likes - 1; - } - _isNotLiked = !_isNotLiked; + numLikes = isNotLiked ? numLikes + 1 : numLikes - 1; + isNotLiked = !isNotLiked; }); } @@ -63,8 +63,8 @@ class _CommentWidgetState extends State { const SizedBox( height: 5, ), - const Text( - "I haven't listened to this song in ages.", + Text( + comment, ), const SizedBox( height: 5, @@ -78,11 +78,10 @@ class _CommentWidgetState extends State { icon: Stack( children: [ Icon(Icons.favorite, - color: _isNotLiked - ? Colors.transparent - : Colors.red), + color: + isNotLiked ? Colors.transparent : Colors.red), Icon(Icons.favorite_border, - color: _isNotLiked ? Colors.black : Colors.red), + color: isNotLiked ? Colors.black : Colors.red), ], ), onPressed: () { @@ -92,7 +91,7 @@ class _CommentWidgetState extends State { const SizedBox( width: 5, ), - Text(_likes.toString()), + Text(numLikes.toString()), const SizedBox( width: 10, ), From 53e53bb4b5adfb01688c69ea2ae9a52d614a58e8 Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Fri, 7 Apr 2023 20:52:48 -0500 Subject: [PATCH 09/11] 3 comments --- lib/screen/comments_screen.dart | 113 +++++++------------------------- lib/widgets/SingleComment.dart | 74 +++++++++++++++++++++ 2 files changed, 99 insertions(+), 88 deletions(-) create mode 100644 lib/widgets/SingleComment.dart diff --git a/lib/screen/comments_screen.dart b/lib/screen/comments_screen.dart index 3d759cf..7d1c013 100644 --- a/lib/screen/comments_screen.dart +++ b/lib/screen/comments_screen.dart @@ -1,109 +1,46 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import '../widgets/my_navigation_bar.dart'; import '../widgets/outlined_button.dart'; import '../widgets/single_comment.dart'; +import '../widgets/SingleComment.dart'; class CommentsScreen extends StatefulWidget { @override - State createState() => - _CommentWidgetState("I haven't listened to this song in ages", 0, true); + State createState() => _CommentsScreenState(); } -class _CommentWidgetState extends State { - _CommentWidgetState(this.comment, this.numLikes, this.isNotLiked); +class _CommentsScreenState extends State { + List _comments = ['A', 'B', 'C']; + List _numLikes = [1, 2, 3]; + List _liked = [true, false, true]; - String comment; - int numLikes; - bool isNotLiked; // if you liked this comment already - // @override - // Widget build(BuildContext context) { - // return Scaffold( - // bottomNavigationBar: const MyNavigationBar(), - // backgroundColor: Theme.of(context).colorScheme.background, - // body: Stack()); - // } - - void _onLikeTapped() { + void _onLikeTapped(int index) { setState(() { - numLikes = isNotLiked ? numLikes + 1 : numLikes - 1; - isNotLiked = !isNotLiked; + _numLikes[index] = + _liked[index] ? _numLikes[index] + 1 : _numLikes[index] - 1; + _liked[index] = !_liked[index]; }); } @override Widget build(BuildContext context) { return Scaffold( - bottomNavigationBar: const MyNavigationBar(), - backgroundColor: Theme.of(context).colorScheme.background, - body: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const CircleAvatar( - backgroundImage: - NetworkImage("https://picsum.photos/250?image=9"), - radius: 18, - ), - const SizedBox( - width: 10, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: const [ - Text("David"), - SizedBox( - width: 5, - ), - Text("32 min ago"), - ], - ), - const SizedBox( - height: 5, - ), - Text( - comment, - ), - const SizedBox( - height: 5, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - IconButton( - padding: EdgeInsets.zero, - constraints: const BoxConstraints(), - icon: Stack( - children: [ - Icon(Icons.favorite, - color: - isNotLiked ? Colors.transparent : Colors.red), - Icon(Icons.favorite_border, - color: isNotLiked ? Colors.black : Colors.red), - ], - ), - onPressed: () { - _onLikeTapped(); - }, - ), - const SizedBox( - width: 5, - ), - Text(numLikes.toString()), - const SizedBox( - width: 10, - ), - InkWell( - child: const Text("Reply"), - onTap: () {}, - ), - ], - ) - ], - ), - ], - )); + bottomNavigationBar: const MyNavigationBar(), + backgroundColor: Theme.of(context).colorScheme.background, + body: ListView.builder( + itemCount: _comments.length, + itemBuilder: (context, index) { + return SingleComment( + comment: _comments[index], + numLikes: _numLikes[index], + isNotLiked: !_liked[index], + onLikeTapped: () => _onLikeTapped(index), + ); + }, + ), + ); } } diff --git a/lib/widgets/SingleComment.dart b/lib/widgets/SingleComment.dart new file mode 100644 index 0000000..f1b54ad --- /dev/null +++ b/lib/widgets/SingleComment.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +class SingleComment extends StatelessWidget { + final String comment; + final int numLikes; + final bool isNotLiked; + final VoidCallback onLikeTapped; + + const SingleComment({ + Key? key, + required this.comment, + required this.numLikes, + required this.isNotLiked, + required this.onLikeTapped, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const CircleAvatar( + backgroundImage: NetworkImage('https://picsum.photos/250?image=9'), + radius: 18, + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + const Text('David'), + const SizedBox(width: 5), + Text( + '32 min ago', + style: Theme.of(context).textTheme.bodyText2, + ), + ], + ), + const SizedBox(height: 5), + Text(comment), + const SizedBox(height: 5), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + IconButton( + padding: EdgeInsets.zero, + constraints: const BoxConstraints(), + icon: Stack( + children: [ + Icon( + Icons.favorite, + color: isNotLiked ? Colors.transparent : Colors.red, + ), + Icon( + Icons.favorite_border, + color: isNotLiked ? Colors.black : Colors.red, + ), + ], + ), + onPressed: onLikeTapped, + ), + const SizedBox(width: 5), + Text(numLikes.toString()), + ], + ), + ], + ), + ), + ], + ); + } +} From ab013c65702b24d64ada6d5876e6d8463848cf29 Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Fri, 7 Apr 2023 21:10:46 -0500 Subject: [PATCH 10/11] style changes --- lib/screen/comments_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/screen/comments_screen.dart b/lib/screen/comments_screen.dart index 7d1c013..aa74c12 100644 --- a/lib/screen/comments_screen.dart +++ b/lib/screen/comments_screen.dart @@ -28,7 +28,7 @@ class _CommentsScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( - bottomNavigationBar: const MyNavigationBar(), + bottomNavigationBar: MyNavigationBar(), backgroundColor: Theme.of(context).colorScheme.background, body: ListView.builder( itemCount: _comments.length, From e9800dd16416571ea61761a74cea960f1eacf6f4 Mon Sep 17 00:00:00 2001 From: anyaguuu Date: Sat, 8 Apr 2023 15:07:24 -0500 Subject: [PATCH 11/11] deleted commented out code --- lib/screen/group_and_profile_screen.dart | 20 -------------------- lib/screen/profile_screen.dart | 20 -------------------- 2 files changed, 40 deletions(-) diff --git a/lib/screen/group_and_profile_screen.dart b/lib/screen/group_and_profile_screen.dart index 3b7ad3f..db404b4 100644 --- a/lib/screen/group_and_profile_screen.dart +++ b/lib/screen/group_and_profile_screen.dart @@ -86,26 +86,6 @@ class ProfileScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: !isGroup ? [ - // Text( - // "200", - // style: - // Theme.of(context).textTheme.displaySmall?.copyWith( - // fontWeight: FontWeight.w600, - // ), - // ), - // Text(" Followers", - // style: Theme.of(context).textTheme.displaySmall), - // const SizedBox(width: 25, height: 2), - // Text( - // "200", - // style: - // Theme.of(context).textTheme.displaySmall?.copyWith( - // fontWeight: FontWeight.w600, - // ), - // ), - // Text(" Following", - // style: Theme.of(context).textTheme.displaySmall) - const SizedBox( width: 100, child: Text("Followers\n 200", diff --git a/lib/screen/profile_screen.dart b/lib/screen/profile_screen.dart index 2cb4b05..8239248 100644 --- a/lib/screen/profile_screen.dart +++ b/lib/screen/profile_screen.dart @@ -86,26 +86,6 @@ class ProfileScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: !group ? [ - // Text( - // "200", - // style: - // Theme.of(context).textTheme.displaySmall?.copyWith( - // fontWeight: FontWeight.w600, - // ), - // ), - // Text(" Followers", - // style: Theme.of(context).textTheme.displaySmall), - // const SizedBox(width: 25, height: 2), - // Text( - // "200", - // style: - // Theme.of(context).textTheme.displaySmall?.copyWith( - // fontWeight: FontWeight.w600, - // ), - // ), - // Text(" Following", - // style: Theme.of(context).textTheme.displaySmall) - const SizedBox( width: 100, child: Text("Followers\n 200",