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

Fluid design #9

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
69 changes: 69 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end

target 'Runner' do
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')

# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}

# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
19 changes: 13 additions & 6 deletions lib/constants/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@

import 'package:flutter/material.dart';

final ThemeData themeData = new ThemeData(
final ThemeData themeData = ThemeData(
fontFamily: 'ProductSans',
brightness: Brightness.light,
primarySwatch: MaterialColor(
AppColors.green[500].value, AppColors.green),
primarySwatch: MaterialColor(AppColors.green[500].value, AppColors.green),
primaryColor: AppColors.green[500],
primaryColorBrightness: Brightness.light,
accentColor: AppColors.green[500],
accentColorBrightness: Brightness.light
);
accentColorBrightness: Brightness.light);

final ThemeData themeDataDark = ThemeData(
fontFamily: 'ProductSans',
brightness: Brightness.dark,
primarySwatch: MaterialColor(AppColors.green[900].value, AppColors.green),
primaryColor: AppColors.green[500],
primaryColorBrightness: Brightness.dark,
accentColor: AppColors.green[500],
accentColorBrightness: Brightness.dark);

class AppColors {
AppColors._(); // this basically makes it so you can instantiate this class
Expand All @@ -49,4 +56,4 @@ class AppColors {
800: const Color(0xFF76af60),
900: const Color(0xFF64a24d)
};
}
}
5 changes: 4 additions & 1 deletion lib/constants/dimens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ class Dimens {
//for all screens
static const double horizontal_padding = 12.0;
static const double vertical_padding = 12.0;
}

static const double tablet_breakpoint = 720.0;
static const double tablet_list_width = 400.0;
}
2 changes: 2 additions & 0 deletions lib/constants/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'app_theme.dart';
export 'dimens.dart';
12 changes: 0 additions & 12 deletions lib/constants/strings.dart

This file was deleted.

1 change: 1 addition & 0 deletions lib/data/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'repository.dart';
1 change: 1 addition & 0 deletions lib/data/local/constants/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'db_constants.dart';
1 change: 1 addition & 0 deletions lib/data/local/datasources/post/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'post_datasource.dart';
2 changes: 1 addition & 1 deletion lib/data/local/datasources/post/post_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ class PostDataSource {
return post;
}).toList();
}
}
}
1 change: 1 addition & 0 deletions lib/data/local/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'app_database.dart';
1 change: 1 addition & 0 deletions lib/data/network/apis/posts/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'post_api.dart';
3 changes: 1 addition & 2 deletions lib/data/network/apis/posts/post_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ class PostApi {

/// Returns list of post in response
Future<PostsList> getPosts() {

return _dioClient
.get(Endpoints.getPosts)
.then((dynamic res) => PostsList.fromJson(res))
.catchError((error) => throw error);
}

/// sample api call with default rest client
/// sample api call with default rest client
// Future<PostsList> getPosts() {
//
// return _restClient
Expand Down
2 changes: 1 addition & 1 deletion lib/data/network/constants/endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class Endpoints {

// booking endpoints
static const String getPosts = baseUrl + "/posts";
}
}
1 change: 1 addition & 0 deletions lib/data/network/constants/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'endpoints.dart';
3 changes: 1 addition & 2 deletions lib/data/network/dio_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ final Dio dio = new Dio()
}));

class DioClient {

// singleton object
static final DioClient _singleton = DioClient._();

Expand All @@ -37,7 +36,7 @@ class DioClient {

// Singleton accessor
static DioClient get instance => DioClient();

// Get:-----------------------------------------------------------------------
Future<dynamic> get(String uri) async {
try {
Expand Down
1 change: 1 addition & 0 deletions lib/data/network/exceptions/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'network_exceptions.dart';
5 changes: 3 additions & 2 deletions lib/data/network/exceptions/network_exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ class NetworkException implements Exception {
}

class AuthException extends NetworkException {
AuthException({message, statusCode}) : super(message: message, statusCode: statusCode);
}
AuthException({message, statusCode})
: super(message: message, statusCode: statusCode);
}
2 changes: 2 additions & 0 deletions lib/data/network/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'dio_client.dart';
export 'rest_client.dart';
10 changes: 6 additions & 4 deletions lib/data/network/rest_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class RestClient {

// factory method to return the same object each time its needed
factory RestClient() => _singleton;

// Singleton accessor
static RestClient get instance => RestClient();

// instantiate json decoder for json serialization
final JsonDecoder _decoder = JsonDecoder();

Expand All @@ -28,7 +28,8 @@ class RestClient {
final int statusCode = response.statusCode;

if (statusCode < 200 || statusCode > 400 || json == null) {
throw NetworkException(message:"Error fetching data from server", statusCode: statusCode);
throw NetworkException(
message: "Error fetching data from server", statusCode: statusCode);
}

print(res);
Expand All @@ -45,7 +46,8 @@ class RestClient {
final int statusCode = response.statusCode;

if (statusCode < 200 || statusCode > 400 || json == null) {
throw NetworkException(message:"Error fetching data from server", statusCode: statusCode);
throw NetworkException(
message: "Error fetching data from server", statusCode: statusCode);
}
return _decoder.convert(res);
});
Expand Down
4 changes: 1 addition & 3 deletions lib/data/repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ class Repository {
.catchError((error) => throw error);

Future<List<Post>> findPostById(int id) {

//creating filter
List<Filter> filters = List();

//check to see if dataLogsType is not null
if (id != null) {
Filter dataLogTypeFilter =
Filter.equal(DBConstants.FIELD_ID, id);
Filter dataLogTypeFilter = Filter.equal(DBConstants.FIELD_ID, id);
filters.add(dataLogTypeFilter);
}

Expand Down
1 change: 1 addition & 0 deletions lib/data/sharedpref/constants/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'preferences.dart';
2 changes: 1 addition & 1 deletion lib/data/sharedpref/constants/preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ class Preferences {

static const String is_logged_in = "isLoggedIn";
static const String auth_token = "authToken";
}
}
1 change: 1 addition & 0 deletions lib/locale/index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'localizations.dart';
106 changes: 106 additions & 0 deletions lib/locale/localizations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// A simple "rough and ready" example of localizing a Flutter app.
// Spanish and English (locale language codes 'en' and 'es') are
// supported.

// The pubspec.yaml file must include flutter_localizations in its
// dependencies section. For example:
//
// dependencies:
// flutter:
// sdk: flutter
// flutter_localizations:
// sdk: flutter

// If you run this app with the device's locale set to anything but
// English or Spanish, the app's locale will be English. If you
// set the device's locale to Spanish, the app's locale will be
// Spanish.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show SynchronousFuture;

class AppLocalizations {
AppLocalizations(this.locale);

final Locale locale;

static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}

static Map<String, Map<String, String>> _localizedValues = {
'en': {
'title': 'Boilerplate Project',
'login_et_user_email': 'Enter user email',
'login_et_user_password': 'Enter password',
'login_btn_forgot_password': 'Forgot Password?',
'login_btn_sign_in': 'Sign In',
'login_validation_error': 'Please fill in all fields',
'posts_title': 'Posts',
'posts_not_found': 'No Posts Found',
'settings_title': 'Settings',
},
'es': {
'title': 'Proyecto repetitivo',
'login_et_user_email': 'Ingrese el email del usuario',
'login_et_user_password': 'introducir la contraseña',
'login_btn_forgot_password': 'Se te olvidó tu contraseña',
'login_btn_sign_in': 'Registrarse',
'login_validation_error': 'Por favor rellena todos los campos',
'posts_title': 'Mensajes',
'posts_not_found': 'No se han encontrado publicacionesd',
'settings_title': 'Ajustes',
},
};

String get title => _localizedValues[locale.languageCode]['title'];
String get login_et_user_email =>
_localizedValues[locale.languageCode]['login_et_user_email'];
String get login_et_user_password =>
_localizedValues[locale.languageCode]['login_et_user_password'];
String get login_btn_forgot_password =>
_localizedValues[locale.languageCode]['login_btn_forgot_password'];
String get login_btn_sign_in =>
_localizedValues[locale.languageCode]['login_btn_sign_in'];
String get login_validation_error =>
_localizedValues[locale.languageCode]['login_validation_error'];
String get posts_title =>
_localizedValues[locale.languageCode]['posts_title'];
String get posts_not_found =>
_localizedValues[locale.languageCode]['posts_not_found'];
String get settings_title =>
_localizedValues[locale.languageCode]['settings_title'];
}

class AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
const AppLocalizationsDelegate();

static List<Locale> get supportedLocales => [
Locale('en', ''),
Locale('es', ''),
];

@override
bool isSupported(Locale locale) {
return supportedLocales
.map((l) => l.languageCode)
.toList()
.contains(locale.languageCode);
}

@override
Future<AppLocalizations> load(Locale locale) {
// Returning a SynchronousFuture here because an async "load" operation
// isn't needed to produce an instance of AppLocalizations.
return SynchronousFuture<AppLocalizations>(AppLocalizations(locale));
}

@override
bool shouldReload(AppLocalizationsDelegate old) => false;
}
Loading