Skip to content

Commit

Permalink
## [0.1.64] - 24th November, 2018
Browse files Browse the repository at this point in the history
* loading indicator update

(cherry picked from commit c572c5a)
  • Loading branch information
tiholic committed Nov 28, 2018
1 parent 6e5910e commit 8036804
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.1.64] - 24th November, 2018

* loading indicator update

## [0.1.63] - 22nd November, 2018

* Bug fixes for offlineProvider response type (changed Map to dynamic)
Expand Down
43 changes: 19 additions & 24 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,40 @@ import 'package:adhara/constants.dart';
abstract class Config {
Map<String, dynamic> _config = {};
Map<String, dynamic> get fromFile => _config;

load() async {
assert(baseURL != null || configFile != null);
if (configFile == null) return;
_config = await AssetFileLoader.load(configFile);
baseURL = fromFile[ConfigKeys.BASE_URL];
dbName = fromFile[ConfigKeys.DB_NAME] ?? dbName;
dbVersion = fromFile[ConfigKeys.DB_VERSION] ?? dbVersion;
sentryDSN = fromFile[ConfigKeys.SENTRY_DSN] ?? sentryDSN;
dataProviderState =
fromFile[ConfigKeys.DATA_PROVIDER_STATE] ?? dataProviderState;
}

Widget get container;

String baseURL;

String configFile;

String dbName = "adhara-app.db";

int dbVersion = 1;

String sentryDSN;

String dataProviderState = ConfigValues.DATA_PROVIDER_STATE_ONLINE;

List<String> get sentryIgnoreStrings => [];

OfflineProvider get offlineProvider => OfflineProvider(this);

NetworkProvider get networkProvider => NetworkProvider(this);

DataInterface get dataInterface;

///Return a map of language vs language properties file
///Ex: {
/// 'en': 'assets/languages/en.properties',
/// 'pt': 'assets/languages/pt.properties'
/// }
Map<String, String> get languageResources => {};

// Widget configs
String fetchingImage = ""; //will be set to null on load
String fetchingIndicator = ConfigValues.FETCHING_INDICATOR_LINEAR;

load() async {
assert(baseURL != null || configFile != null);
if (configFile == null) return;
_config = await AssetFileLoader.load(configFile);
baseURL = fromFile[ConfigKeys.BASE_URL];
dbName = fromFile[ConfigKeys.DB_NAME] ?? dbName;
dbVersion = fromFile[ConfigKeys.DB_VERSION] ?? dbVersion;
sentryDSN = fromFile[ConfigKeys.SENTRY_DSN] ?? sentryDSN;
dataProviderState =
fromFile[ConfigKeys.DATA_PROVIDER_STATE] ?? dataProviderState;
// widget configs
fetchingImage = fetchingImage ?? ((fetchingImage!="")?fetchingImage:fromFile[ConfigKeys.FETCHING_IMAGE]) ?? null;
fetchingIndicator = fromFile[ConfigKeys.FETCHING_INDICATOR];
}
}
4 changes: 4 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ class ConfigKeys {
static const String DB_VERSION = "dbVersion";
static const String SENTRY_DSN = "sentryDSN";
static const String DATA_PROVIDER_STATE = "dataProviderState";
static const String FETCHING_IMAGE = "fetchingImage";
static const String FETCHING_INDICATOR = "fetchignIndicator";
}

class ConfigValues {
static const String DATA_PROVIDER_STATE_OFFLINE = "offline";
static const String DATA_PROVIDER_STATE_ONLINE = "online";
static const String FETCHING_INDICATOR_LINEAR = "linear";
static const String FETCHING_INDICATOR_CIRCULAR = "circular";
}
75 changes: 46 additions & 29 deletions lib/widgets/fetching.dart
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
import 'package:adhara/constants.dart';
import 'package:adhara/resources/r.dart';
import 'package:adhara/styles/text_styles.dart';
import 'package:adhara/widgets/no_data.dart';
import 'package:flutter/material.dart';

import '../resources/r.dart';
import '../styles/text_styles.dart';
import 'no_data.dart';

class Fetching extends NoData {
final String text;
final Widget bottom;
final TextStyle textStyle;
final String assetPath;

Fetching(
{Key key,
this.bottom,
this.text: "Loading...",
this.textStyle: AdharaStyles.textMuted,
this.assetPath})
: super(key: key);
Fetching({
Key key,
this.bottom,
this.text: "Loading...",
this.textStyle: AdharaStyles.textMuted,
this.assetPath
}) : super(key: key);

Widget getTop(r){
String _assetPath = assetPath ?? r.config.fromFile['fetchingImage'];
if(_assetPath == null) return Container();
return Container(
width: 120.0,
child: Center(child: Image.asset(_assetPath)),
);
}

Widget getCenter(){
if(text == null) return Container();
return Text(
text,
style: textStyle,
textAlign: TextAlign.center,
);
}

Widget getBottom(Resources r){
return SizedBox(
width: 100.0,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: r.config.fetchingIndicator==ConfigValues.FETCHING_INDICATOR_CIRCULAR?CircularProgressIndicator():LinearProgressIndicator(),
),
);
}

@override
Widget buildWithResources(BuildContext context, Resources r) {
String _assetPath = assetPath ??
r.config.fromFile['fetchingImage'] ??
"assets/animations/fetching.gif";
return Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 120.0,
child: Center(child: Image.asset(_assetPath)),
),
bottom ?? text != null
? Text(
text,
style: textStyle,
textAlign: TextAlign.center,
)
: Container(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
getTop(r),
getCenter(),
getBottom(r)
]));
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: adhara
description: Base framework for Flutter Apps with intense networking and data interactivity
version: 0.1.63
version: 0.1.64
author: Rohit R. Abbadi <[email protected]>
homepage: https://infitio.com

Expand Down

0 comments on commit 8036804

Please sign in to comment.