Skip to content

Commit 4acba82

Browse files
author
Ananthu P Kanive
authored
Merge pull request #13 from LonelyCpp/documentation
Documentation & readme update
2 parents 76e6be9 + 30f642d commit 4acba82

16 files changed

+41
-24
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This is my first project on my journey to learning and understanding flutter and
55

66
![android](./screenshots/android.png?raw=true 'android')
77
![ios](./screenshots/ios.gif?raw=true 'ios')
8+
![ios](./screenshots/ios_chart.gif?raw=true 'ios')
89

910
## Features
1011
- :white_check_mark: Beautiful minimal UI
@@ -14,6 +15,7 @@ This is my first project on my journey to learning and understanding flutter and
1415
- :white_check_mark: 5 day forecast
1516
- :white_check_mark: Beautifully animated transitions
1617
- :white_check_mark: BLoC pattern for API calls
18+
- :white_check_mark: Line graph to show temperature variance
1719

1820
## Getting Started
1921

lib/src/api/http_exception.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/// represents an error state from an network API request
2+
/// [code] represents the HTTP response code
3+
/// string [message] reason if any
14
class HTTPException implements Exception {
25
final int code;
36
final String message;
@@ -8,5 +11,4 @@ class HTTPException implements Exception {
811
String toString() {
912
return 'HTTPException{code: $code, message: $message}';
1013
}
11-
1214
}

lib/src/api/weather_api_client.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:flutter_weather/src/model/weather.dart';
44
import 'package:meta/meta.dart';
55
import 'package:http/http.dart' as http;
66

7+
/// Wrapper around the open weather map api
8+
/// https://openweathermap.org/current
79
class WeatherApiClient {
810
static const baseUrl = 'http://api.openweathermap.org';
911
final apiKey;

lib/src/bloc/weather_bloc.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ class WeatherBloc extends Bloc<WeatherEvent, WeatherState> {
2323
if (event is FetchWeather) {
2424
yield WeatherLoading();
2525
try {
26-
final Weather weather =
27-
await weatherRepository.getWeather(event.cityName, latitude: event.latitude, longitude: event.longitude);
26+
final Weather weather = await weatherRepository.getWeather(
27+
event.cityName,
28+
latitude: event.latitude,
29+
longitude: event.longitude);
2830
yield WeatherLoaded(weather: weather);
2931
} catch (exception) {
3032
print(exception);

lib/src/repository/weather_repository.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ class WeatherRepository {
77
WeatherRepository({@required this.weatherApiClient})
88
: assert(weatherApiClient != null);
99

10-
Future<Weather> getWeather(String cityName, {double latitude, double longitude}) async {
11-
if(cityName == null){
12-
cityName = await weatherApiClient.getCityNameFromLocation(latitude: latitude, longitude: longitude);
10+
Future<Weather> getWeather(String cityName,
11+
{double latitude, double longitude}) async {
12+
if (cityName == null) {
13+
cityName = await weatherApiClient.getCityNameFromLocation(
14+
latitude: latitude, longitude: longitude);
1315
}
1416
var weather = await weatherApiClient.getWeatherData(cityName);
1517
var weathers = await weatherApiClient.getForecast(cityName);

lib/src/screens/settings_screen.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class SettingsScreen extends StatelessWidget {
1515
padding: EdgeInsets.only(left: 10, right: 10, top: 15),
1616
color: AppStateContainer.of(context).theme.primaryColor,
1717
child: ListView(
18-
// crossAxisAlignment: CrossAxisAlignment.start,
1918
children: <Widget>[
2019
Padding(
2120
padding: const EdgeInsets.all(8.0),

lib/src/screens/weather_screen.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ class _WeatherScreenState extends State<WeatherScreen>
232232

233233
Position position = await Geolocator()
234234
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);
235-
print(position);
236235
_weatherBloc.dispatch(FetchWeather(
237236
longitude: position.longitude, latitude: position.latitude));
238237
}
@@ -253,7 +252,7 @@ class _WeatherScreenState extends State<WeatherScreen>
253252
style: TextStyle(color: Colors.green, fontSize: 16),
254253
),
255254
onPressed: () {
256-
permissionHandler.openAppSettings().then((val) => print(val));
255+
permissionHandler.openAppSettings();
257256
Navigator.of(context).pop();
258257
},
259258
),

lib/src/utils/WeatherIconMapper.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ class _IconData extends IconData {
77
fontFamily: 'WeatherIcons',
88
);
99
}
10-
10+
/// Exposes specific weather icons
11+
/// Has all weather conditions specified by open weather maps API
12+
/// https://openweathermap.org/weather-conditions
13+
// hex values and ttf file from https://erikflowers.github.io/weather-icons/
1114
class WeatherIcons {
1215
static const IconData clear_day = const _IconData(0xf00d);
1316
static const IconData clear_night = const _IconData(0xf02e);

lib/src/widgets/current_conditions.dart

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import 'package:flutter_weather/main.dart';
33
import 'package:flutter_weather/src/model/weather.dart';
44
import 'package:flutter_weather/src/widgets/value_tile.dart';
55

6+
/// Renders Weather Icon, current, min and max temperatures
67
class CurrentConditions extends StatelessWidget {
7-
88
final Weather weather;
9-
109
const CurrentConditions({Key key, this.weather}) : super(key: key);
1110

1211
@override
@@ -33,16 +32,14 @@ class CurrentConditions extends StatelessWidget {
3332
ValueTile("max",
3433
'${this.weather.maxTemperature.as(AppStateContainer.of(context).temperatureUnit).round()}°'),
3534
Padding(
36-
padding: const EdgeInsets.only(left: 20, right: 20),
35+
padding: const EdgeInsets.only(left: 15, right: 15),
3736
child: Center(
3837
child: Container(
39-
width: 1,
40-
height: 30,
41-
color: AppStateContainer.of(context)
42-
.theme
43-
.accentColor
44-
.withAlpha(50),
45-
)),
38+
width: 1,
39+
height: 30,
40+
color:
41+
AppStateContainer.of(context).theme.accentColor.withAlpha(50),
42+
)),
4643
),
4744
ValueTile("min",
4845
'${this.weather.minTemperature.as(AppStateContainer.of(context).temperatureUnit).round()}°'),

lib/src/widgets/forecast_horizontal_widget.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import 'package:flutter_weather/src/model/weather.dart';
44
import 'package:flutter_weather/src/widgets/value_tile.dart';
55
import 'package:intl/intl.dart';
66

7+
/// Renders a horizontal scrolling list of weather conditions
8+
/// Used to show forecast
9+
/// Shows DateTime, Weather Condition icon and Temperature
710
class ForecastHorizontal extends StatelessWidget {
811
const ForecastHorizontal({
912
Key key,

0 commit comments

Comments
 (0)