Skip to content

Commit

Permalink
Home carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
MaironLucas committed Sep 3, 2024
1 parent 866d3a7 commit db7b5e1
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 107 deletions.
51 changes: 51 additions & 0 deletions lib/presentation/home/common/game_chip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';

class GameChip extends StatelessWidget {
const GameChip({
required this.homeTeamLogo,
required this.visitorTeamLogo,
required this.homeTeamScore,
required this.visitorTeamScore,
super.key,
});

final String homeTeamLogo;
final String visitorTeamLogo;
final String homeTeamScore;
final String visitorTeamScore;

@override
Widget build(BuildContext context) => Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Theme.of(context).colorScheme.outline,
width: 3,
),
),
padding: EdgeInsets.all(4),
child: Column(
children: [
Expanded(
child: Image.network(
homeTeamLogo,
),
),
Text(
homeTeamScore,
style: Theme.of(context).textTheme.bodyMedium,
),
Text(
visitorTeamScore,
style: Theme.of(context).textTheme.bodyMedium,
),
Expanded(
child: Image.network(
visitorTeamLogo,
),
),
],
),
);
}
207 changes: 203 additions & 4 deletions lib/presentation/home/home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
GetLiveGames event,
Emitter<HomeState> emitter,
) async {
final useMock = false;
final useMock = true;
emitter(HomeLoading());
try {
await Future.delayed(Duration(seconds: 2));
final liveGames = await _getLiveGamesUC.getFuture(null);
emitter(
HomeSuccess(
liveGames: !useMock
? liveGames
? (await _getLiveGamesUC.getFuture(null))
: [
GameSummary(
date: DateTime.now(),
Expand Down Expand Up @@ -80,8 +79,208 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
name: 'Atlanta Hawks',
nickName: 'Lakers',
code: 'LKR',
logoUrl: 'https://upload.wikimedia.org/wikipedia/fr/e/ee/Hawks_2016.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
nickName: 'Celtics',
code: 'BCS',
logoUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Brooklyn_Nets_newlogo.svg/130px-Brooklyn_Nets_newlogo.svg.png'),
homeTeamScore: TeamScore(
wins: 10,
loses: 5,
points: 120,
),
visitorTeamScore: TeamScore(
wins: 13,
loses: 2,
points: 100,
),
),
GameSummary(
date: DateTime.now(),
period: 1,
gameStatus: GameStatus(
isFinished: false,
isHalfTime: false,
),
id: '123',
arenaName: 'Crypto Arena',
homeTeam: Team(
id: 'hasd',
name: 'Los Angeles Lakers',
nickName: 'Lakers',
code: 'LKR',
logoUrl:
'https://upload.wikimedia.org/wikipedia/fr/e/ee/Hawks_2016.png'),
'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Los_Angeles_Lakers_logo.svg/220px-Los_Angeles_Lakers_logo.svg.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
nickName: 'Celtics',
code: 'BCS',
logoUrl:
'https://upload.wikimedia.org/wikipedia/fr/thumb/6/65/Celtics_de_Boston_logo.svg/1024px-Celtics_de_Boston_logo.svg.png'),
homeTeamScore: TeamScore(
wins: 10,
loses: 5,
points: 27,
),
visitorTeamScore: TeamScore(
wins: 13,
loses: 2,
points: 33,
),
),
GameSummary(
date: DateTime.now(),
period: 4,
gameStatus: GameStatus(
isFinished: false,
isHalfTime: false,
),
id: '123',
arenaName: 'Crypto Arena',
homeTeam: Team(
id: 'hasd',
name: 'Atlanta Hawks',
nickName: 'Lakers',
code: 'LKR',
logoUrl: 'https://upload.wikimedia.org/wikipedia/fr/e/ee/Hawks_2016.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
nickName: 'Celtics',
code: 'BCS',
logoUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Brooklyn_Nets_newlogo.svg/130px-Brooklyn_Nets_newlogo.svg.png'),
homeTeamScore: TeamScore(
wins: 10,
loses: 5,
points: 120,
),
visitorTeamScore: TeamScore(
wins: 13,
loses: 2,
points: 100,
),
),
GameSummary(
date: DateTime.now(),
period: 1,
gameStatus: GameStatus(
isFinished: false,
isHalfTime: false,
),
id: '123',
arenaName: 'Crypto Arena',
homeTeam: Team(
id: 'hasd',
name: 'Los Angeles Lakers',
nickName: 'Lakers',
code: 'LKR',
logoUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Los_Angeles_Lakers_logo.svg/220px-Los_Angeles_Lakers_logo.svg.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
nickName: 'Celtics',
code: 'BCS',
logoUrl:
'https://upload.wikimedia.org/wikipedia/fr/thumb/6/65/Celtics_de_Boston_logo.svg/1024px-Celtics_de_Boston_logo.svg.png'),
homeTeamScore: TeamScore(
wins: 10,
loses: 5,
points: 27,
),
visitorTeamScore: TeamScore(
wins: 13,
loses: 2,
points: 33,
),
),
GameSummary(
date: DateTime.now(),
period: 4,
gameStatus: GameStatus(
isFinished: false,
isHalfTime: false,
),
id: '123',
arenaName: 'Crypto Arena',
homeTeam: Team(
id: 'hasd',
name: 'Atlanta Hawks',
nickName: 'Lakers',
code: 'LKR',
logoUrl: 'https://upload.wikimedia.org/wikipedia/fr/e/ee/Hawks_2016.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
nickName: 'Celtics',
code: 'BCS',
logoUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Brooklyn_Nets_newlogo.svg/130px-Brooklyn_Nets_newlogo.svg.png'),
homeTeamScore: TeamScore(
wins: 10,
loses: 5,
points: 120,
),
visitorTeamScore: TeamScore(
wins: 13,
loses: 2,
points: 100,
),
),
GameSummary(
date: DateTime.now(),
period: 1,
gameStatus: GameStatus(
isFinished: false,
isHalfTime: false,
),
id: '123',
arenaName: 'Crypto Arena',
homeTeam: Team(
id: 'hasd',
name: 'Los Angeles Lakers',
nickName: 'Lakers',
code: 'LKR',
logoUrl:
'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Los_Angeles_Lakers_logo.svg/220px-Los_Angeles_Lakers_logo.svg.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
nickName: 'Celtics',
code: 'BCS',
logoUrl:
'https://upload.wikimedia.org/wikipedia/fr/thumb/6/65/Celtics_de_Boston_logo.svg/1024px-Celtics_de_Boston_logo.svg.png'),
homeTeamScore: TeamScore(
wins: 10,
loses: 5,
points: 27,
),
visitorTeamScore: TeamScore(
wins: 13,
loses: 2,
points: 33,
),
),
GameSummary(
date: DateTime.now(),
period: 4,
gameStatus: GameStatus(
isFinished: false,
isHalfTime: false,
),
id: '123',
arenaName: 'Crypto Arena',
homeTeam: Team(
id: 'hasd',
name: 'Atlanta Hawks',
nickName: 'Lakers',
code: 'LKR',
logoUrl: 'https://upload.wikimedia.org/wikipedia/fr/e/ee/Hawks_2016.png'),
visitorTeam: Team(
id: 'hasd',
name: 'Boston Celtics',
Expand Down
Loading

0 comments on commit db7b5e1

Please sign in to comment.