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 3 commits
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
Binary file removed assets/thunder.png
Binary file not shown.
Binary file added assets/weather/clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weather/cloudy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weather/rainy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/weather/thunderstorms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:just_audio/just_audio.dart';
import 'package:music_repository/music_repository.dart';
import 'package:weather_repository/weather_repository.dart';

class App extends StatelessWidget {
const App({super.key});
Expand All @@ -13,6 +14,9 @@ class App extends StatelessWidget {
Widget build(BuildContext context) {
return MultiRepositoryProvider(
providers: [
RepositoryProvider(
create: (context) => WeatherRepository(),
),
RepositoryProvider(
create: (context) => MusicRepository(),
),
Expand Down
30 changes: 29 additions & 1 deletion lib/generated/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
"welcomeMessage": "Welcome on board",
"welcomeSubtitle": "Lunch will be served in\n10 minutes",
"assistButton": "ASSIST",
"clear": "Clear",
"cloudy": "Cloudy",
"rainy": "Rainy",
"thunderstorms": "Thunderstorms"
}
1 change: 1 addition & 0 deletions lib/overview/view/overview_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';

class OverviewPage extends StatelessWidget {
Expand Down
106 changes: 0 additions & 106 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';
31 changes: 31 additions & 0 deletions lib/weather/cubit/weather_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'dart:async';

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

class WeatherCubit extends Cubit<WeatherInfo?> {
WeatherCubit({
required WeatherRepository weatherRepository,
}) : _weatherRepository = weatherRepository,
super(null) {
jneschisi marked this conversation as resolved.
Show resolved Hide resolved
_weatherSubscription =
_weatherRepository.weatherStream.listen(_onWeatherInfo);
}

final WeatherRepository _weatherRepository;
late final StreamSubscription<WeatherInfo> _weatherSubscription;

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

void initialize() {
_onWeatherInfo(_weatherRepository.weather);
}

@override
Future<void> close() {
_weatherSubscription.cancel();
return super.close();
}
}
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