Skip to content

Commit

Permalink
* Added info dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
micer committed Jan 23, 2021
1 parent bfbcbe9 commit 1b20bb0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Project specific
**/google-services.json

# Miscellaneous
*.class
*.lock
Expand Down
72 changes: 57 additions & 15 deletions lib/page/flights_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:gibraltar_flights/util/extensions.dart';
import 'package:gibraltar_flights/util/scrappy.dart';
import 'package:intl/intl.dart' hide TextDirection;
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:rflutter_alert/rflutter_alert.dart';

class FlightsPage extends StatefulWidget {
const FlightsPage({Key key, @required this.title}) : super(key: key);
Expand All @@ -20,7 +21,7 @@ class FlightsPage extends StatefulWidget {
class _FlightsPageState extends State<FlightsPage> {
Flights flights;
RefreshController _refreshController =
RefreshController(initialRefresh: true);
RefreshController(initialRefresh: true);
double _refreshButtonOpacity = 1;

@override
Expand All @@ -34,15 +35,39 @@ class _FlightsPageState extends State<FlightsPage> {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.info_outline,
color: Colors.white,
),
onPressed: () =>
Alert(
context: context,
title: "Thanks for using this app!",
desc: "Made with ❤️ during 2020/21 pandemic times.",
image: Image.asset("assets/launcher/ic_launcher_foreground.png"),
buttons: [
DialogButton(
onPressed: () => Navigator.pop(context),
child: Text(
"CLOSE",
style: TextStyle(color: Colors.white, fontSize: 16),
),
)
]
).show()
)
],
),
body: Center(
child: SmartRefresher(
enablePullDown: true,
enablePullUp: false,
controller: _refreshController,
onRefresh: () => _onRefresh(context),
child: _listView(),
)));
enablePullDown: true,
enablePullUp: false,
controller: _refreshController,
onRefresh: () => _onRefresh(context),
child: _listView(),
)));
}

Widget _listView() {
Expand Down Expand Up @@ -77,7 +102,9 @@ class _FlightsPageState extends State<FlightsPage> {
child: Text("refresh".toUpperCase()),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: Theme.of(context).accentColor,
backgroundColor: Theme
.of(context)
.accentColor,
onSurface: Colors.grey,
)),
),
Expand Down Expand Up @@ -150,7 +177,9 @@ class _FlightsPageState extends State<FlightsPage> {

void _showError(BuildContext context, String message) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(message), backgroundColor: Theme.of(context).errorColor));
content: Text(message), backgroundColor: Theme
.of(context)
.errorColor));
}
}

Expand All @@ -173,13 +202,20 @@ class HeadingItem implements ListItem {
return Container(
child: Text(
heading,
style: Theme.of(context).textTheme.headline5,
style: Theme
.of(context)
.textTheme
.headline5,
),
alignment: Alignment.center,
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: Theme.of(context).primaryColorLight,
border: Border.all(color: Theme.of(context).accentColor),
color: Theme
.of(context)
.primaryColorLight,
border: Border.all(color: Theme
.of(context)
.accentColor),
borderRadius: BorderRadius.circular(8)),
);
}
Expand Down Expand Up @@ -215,7 +251,9 @@ class FlightItem implements ListItem {
textDirection: TextDirection.ltr,
child: SvgPicture.asset(
type == "arrival" ? IconNames.arrivals : IconNames.departures,
color: Theme.of(context).accentColor,
color: Theme
.of(context)
.accentColor,
matchTextDirection: true,
)),
);
Expand All @@ -229,14 +267,18 @@ class FlightItem implements ListItem {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(time, style: Theme.of(context).textTheme.headline5),
Text(time, style: Theme
.of(context)
.textTheme
.headline5),
Container(
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: _getStatusColor(),
borderRadius: BorderRadius.circular(4)),
child: Text(status,
style: Theme.of(context)
style: Theme
.of(context)
.textTheme
.caption
.apply(color: Colors.white)),
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies:
jiffy: ^3.0.1
path_provider: ^1.6.24
pull_to_refresh: ^1.6.3
rflutter_alert: ^1.1.0
scrapy: ^0.0.3

dev_dependencies:
Expand Down Expand Up @@ -63,6 +64,7 @@ flutter:
assets:
- assets/arrivals.svg
- assets/departures.svg
- assets/launcher/ic_launcher_foreground.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down

0 comments on commit 1b20bb0

Please sign in to comment.