Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fake realtime weather #8

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/overview/cubit/cubit.dart

This file was deleted.

10 changes: 0 additions & 10 deletions lib/overview/cubit/overview_state.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/overview/overview.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export 'cubit/cubit.dart';
export 'view/view.dart';
export 'widgets/widgets.dart';
40 changes: 15 additions & 25 deletions lib/overview/view/overview_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:aes_ui/aes_ui.dart';
import 'package:airplane_entertainment_system/l10n/l10n.dart';
import 'package:airplane_entertainment_system/overview/overview.dart';
import 'package:airplane_entertainment_system/weather/weather.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class OverviewPage extends StatelessWidget {
const OverviewPage({super.key});
Expand All @@ -11,17 +11,10 @@ class OverviewPage extends StatelessWidget {
Widget build(BuildContext context) {
final layout = AesLayout.of(context);

return BlocProvider(
create: (_) => OverviewCubit(
weatherRepository: context.read(),
)..initialize(),
child: switch (layout) {
AesLayoutData.small => const _SmallOverviewPage(),
AesLayoutData.medium ||
AesLayoutData.large =>
const _LargeOverviewPage(),
},
);
return switch (layout) {
AesLayoutData.small => const _SmallOverviewPage(),
AesLayoutData.medium || AesLayoutData.large => const _LargeOverviewPage(),
};
}
}

Expand Down Expand Up @@ -72,21 +65,18 @@ class DashBoard extends StatelessWidget {

@override
Widget build(BuildContext context) {
final weatherInfo =
context.select((OverviewCubit cubit) => cubit.state.weatherInfo);

return ListView(
padding: padding,
children: [
const WelcomeCopy(),
const SizedBox(height: 40),
const FlightTrackingCard(),
const SizedBox(height: 20),
WeatherCard(info: weatherInfo),
const SizedBox(height: 20),
const MusicCard(),
const SizedBox(height: 20),
const MovieCard(),
children: const [
WelcomeCopy(),
SizedBox(height: 40),
FlightTrackingCard(),
SizedBox(height: 20),
WeatherCard(),
SizedBox(height: 20),
MusicCard(),
SizedBox(height: 20),
MovieCard(),
],
);
}
Expand Down
151 changes: 0 additions & 151 deletions lib/overview/widgets/weather_card.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/overview/widgets/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export 'airplane_image.dart';
export 'flight_tracking_card.dart';
export 'movie_card.dart';
export 'music_card.dart';
export 'weather_card.dart';
1 change: 1 addition & 0 deletions lib/weather/cubit/cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'weather_cubit.dart';
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import 'dart:async';

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:weather_repository/weather_repository.dart';

part 'overview_state.dart';

class OverviewCubit extends Cubit<OverviewState> {
OverviewCubit({
class WeatherCubit extends Cubit<WeatherInfo?> {
WeatherCubit({
required WeatherRepository weatherRepository,
}) : _weatherRepository = weatherRepository,
super(const OverviewState()) {
super(null) {
_weatherSubscription =
_weatherRepository.weatherStream.listen(_onWeatherInfo);
}
Expand All @@ -19,7 +16,7 @@ class OverviewCubit extends Cubit<OverviewState> {
late final StreamSubscription<WeatherInfo> _weatherSubscription;

void _onWeatherInfo(WeatherInfo weatherInfo) {
emit(OverviewState(weatherInfo: weatherInfo));
emit(weatherInfo);
}

void initialize() {
Expand Down
1 change: 1 addition & 0 deletions lib/weather/view/view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'weather_card.dart';
Loading