Cache image files

This commit is contained in:
unknown 2018-06-13 13:13:12 -07:00
parent 567b8544c9
commit 9b352887c1
3 changed files with 56 additions and 11 deletions

View File

@ -11,6 +11,7 @@ import 'package:invoiceninja/ui/dashboard/dashboard_screen.dart';
import 'package:invoiceninja/ui/product/product_screen.dart';
import 'package:invoiceninja/utils/localization.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:cached_network_image/cached_network_image.dart';
class AppDrawer extends StatelessWidget {
final AppDrawerVM viewModel;
@ -37,12 +38,13 @@ class AppDrawer extends StatelessWidget {
child: new DropdownButton<String>(
isDense: true,
value: viewModel.selectedCompanyIndex,
items: viewModel.companies.map((CompanyEntity company) =>
DropdownMenuItem<String>(
value: (viewModel.companies.indexOf(company) + 1).toString(),
child: Text(company.name),
)
).toList(),
items: viewModel.companies
.map((CompanyEntity company) => DropdownMenuItem<String>(
value:
(viewModel.companies.indexOf(company) + 1).toString(),
child: Text(company.name),
))
.toList(),
onChanged: (value) {
viewModel.onCompanyChanged(context, value);
},
@ -59,13 +61,21 @@ class AppDrawer extends StatelessWidget {
children: <Widget>[
Expanded(
child: Center(
child: viewModel.selectedCompany.logoUrl != null ? Image.network(viewModel.selectedCompany.logoUrl) : null
),
child: viewModel.selectedCompany.logoUrl != null
//? Image.network(viewModel.selectedCompany.logoUrl)
? CachedNetworkImage(
imageUrl: viewModel.selectedCompany.logoUrl,
placeholder: new CircularProgressIndicator(),
errorWidget: new Icon(Icons.error),
)
: null),
),
SizedBox(
height: 18.0,
),
viewModel.companies.length > 1 ? _multipleCompanies : _singleCompany,
viewModel.companies.length > 1
? _multipleCompanies
: _singleCompany,
],
)),
color: Colors.white10,
@ -92,7 +102,9 @@ class AppDrawer extends StatelessWidget {
leading: Icon(FontAwesomeIcons.cube, size: 22.0),
title: Text(AppLocalization.of(context).products),
onTap: () {
StoreProvider.of<AppState>(context).dispatch(SearchProducts(null));
StoreProvider
.of<AppState>(context)
.dispatch(SearchProducts(null));
Navigator.of(context).pushReplacementNamed(ProductScreen.route);
},
),
@ -113,7 +125,11 @@ class AppDrawer extends StatelessWidget {
),
AboutListTile(
applicationName: 'Invoice Ninja',
applicationIcon: Image.asset('assets/images/logo.png', width: 40.0, height: 40.0,),
applicationIcon: Image.asset(
'assets/images/logo.png',
width: 40.0,
height: 40.0,
),
applicationVersion: 'v' + kAppVersion,
icon: Icon(FontAwesomeIcons.info, size: 22.0),
),

View File

@ -85,6 +85,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "5.4.5"
cached_network_image:
dependency: "direct main"
description:
name: cached_network_image
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1+1"
charcode:
dependency: transitive
description:
@ -160,6 +167,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_cache_manager:
dependency: transitive
description:
name: flutter_cache_manager
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
flutter_driver:
dependency: "direct dev"
description: flutter
@ -495,6 +509,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0+1"
term_glyph:
dependency: transitive
description:
@ -530,6 +551,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.0+4"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.3"
vector_math:
dependency: transitive
description:

View File

@ -20,6 +20,7 @@ dependencies:
built_collection: "^3.1.1"
memoize: "^1.4.0"
url_launcher: "^3.0.2"
cached_network_image: "^0.4.1"
dev_dependencies:
flutter_driver: