Adds veggieseasons preferences, tweaks styles + list page (#37)

pull/39/head
Andrew Brogdon 6 years ago committed by GitHub
parent 60837792a1
commit 2a2c535aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"

@ -1 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"

@ -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

@ -0,0 +1,22 @@
PODS:
- Flutter (1.0.0)
- shared_preferences (0.0.1):
- Flutter
DEPENDENCIES:
- Flutter (from `.symlinks/flutter/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
EXTERNAL SOURCES:
Flutter:
:path: ".symlinks/flutter/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
SPEC CHECKSUMS:
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
shared_preferences: 5a1d487c427ee18fcd3ea1f2a131569481834b53
PODFILE CHECKSUM: aff02bfeed411c636180d6812254b2daeea14d09
COCOAPODS: 1.5.3

@ -12,6 +12,7 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
47E38CB637A3AA73076EECED /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86058174F9D63E2DE07832CF /* libPods-Runner.a */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
@ -46,6 +47,7 @@
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
86058174F9D63E2DE07832CF /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
@ -64,6 +66,7 @@
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
47E38CB637A3AA73076EECED /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -90,7 +93,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
B83F3512278D995641099164 /* Pods */,
EDD57F43E75C224779ECECFA /* Frameworks */,
);
sourceTree = "<group>";
};
@ -126,6 +130,21 @@
name = "Supporting Files";
sourceTree = "<group>";
};
B83F3512278D995641099164 /* Pods */ = {
isa = PBXGroup;
children = (
);
name = Pods;
sourceTree = "<group>";
};
EDD57F43E75C224779ECECFA /* Frameworks */ = {
isa = PBXGroup;
children = (
86058174F9D63E2DE07832CF /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -133,12 +152,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
A569513836A421DB07D1027A /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
0DC0F46900A3E3B63DFB1DE6 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -198,6 +219,24 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
0DC0F46900A3E3B63DFB1DE6 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@ -226,6 +265,24 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
A569513836A421DB07D1027A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */

@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

@ -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>

@ -0,0 +1,82 @@
// Copyright 2018 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:scoped_model/scoped_model.dart';
import 'package:veggieseasons/data/veggie.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// A model class that mirrors the options in [SettingsScreen] and stores data
/// in shared preferences.
class Preferences extends Model {
Preferences() {
_loadingFuture = _load();
}
// Keys to use with shared preferences.
static const _caloriesKey = 'calories';
static const _preferredCategoriesKey = 'preferredCategories';
// Indicates whether a call to [_load] is in progress;
Future<void> _loadingFuture;
int _desiredCalories = 2000;
Set<VeggieCategory> _preferredCategories = Set<VeggieCategory>();
Future<int> get desiredCalories async {
await _loadingFuture;
return _desiredCalories;
}
Future<Set<VeggieCategory>> get preferredCategories async {
await _loadingFuture;
return Set.from(_preferredCategories);
}
void addPreferredCategory(VeggieCategory category) {
_preferredCategories.add(category);
_save();
notifyListeners();
}
void removePreferredCategory(VeggieCategory category) {
_preferredCategories.remove(category);
_save();
notifyListeners();
}
void setDesiredCalories(int calories) {
_desiredCalories = calories;
_save();
notifyListeners();
}
Future<void> _save() async {
final prefs = await SharedPreferences.getInstance();
prefs.setInt(_caloriesKey, _desiredCalories);
// Store preferred categories as a comma-separated string containing their
// indices.
prefs.setString(_preferredCategoriesKey,
_preferredCategories.map((c) => c.index.toString()).join(','));
}
Future<void> _load() async {
final prefs = await SharedPreferences.getInstance();
_desiredCalories = prefs.getInt(_caloriesKey) ?? 2000;
_preferredCategories.clear();
final names = prefs.getString(_preferredCategoriesKey) ?? '';
for (final name in names.split(',')) {
final index = int.parse(name) ?? 0;
if (VeggieCategory.values[index] != null) {
_preferredCategories.add(VeggieCategory.values[index]);
}
}
notifyListeners();
}
}

@ -9,13 +9,19 @@ import 'package:veggieseasons/data/model.dart';
import 'package:veggieseasons/data/veggie.dart';
import 'package:veggieseasons/styles.dart';
/// A circular widget that indicates in which seasons a particular veggie can be
/// harvested. It displays the first two letters of the season and uses a
/// different background color to represent each of the seasons as well.
/// A circular widget that represents a season of the year.
///
/// The season can be displayed as a valid harvest season or one during which a
/// particular veggie cannot be harvested. Bright colors are used in the first
/// case, and grays in the latter.
class SeasonCircle extends StatelessWidget {
SeasonCircle(this.season, this.isHarvestTime);
/// Season to be displayed by this widget.
final Season season;
SeasonCircle(this.season);
/// Whether or not [season] should be presented as a valid harvest season.
final bool isHarvestTime;
String get _firstChars {
return '${season.toString().substring(7, 8).toUpperCase()}'
@ -28,7 +34,9 @@ class SeasonCircle extends StatelessWidget {
padding: const EdgeInsets.all(4.0),
child: DecoratedBox(
decoration: BoxDecoration(
color: Styles.seasonColors[season],
color: isHarvestTime
? Styles.seasonColors[season]
: Styles.transparentColor,
borderRadius: BorderRadius.circular(25.0),
border: Styles.seasonBorder,
),
@ -36,7 +44,12 @@ class SeasonCircle extends StatelessWidget {
height: 50.0,
width: 50.0,
child: Center(
child: Text(_firstChars, style: Styles.seasonText),
child: Text(
_firstChars,
style: isHarvestTime
? Styles.activeSeasonText
: Styles.inactiveSeasonText,
),
),
),
),
@ -116,8 +129,9 @@ class DetailsScreen extends StatelessWidget {
mainAxisSize: MainAxisSize.max,
children: [
Wrap(
children:
veggie.seasons.map<Widget>((s) => SeasonCircle(s)).toList(),
children: Season.values.map((s) {
return SeasonCircle(s, veggie.seasons.contains(s));
}).toList(),
),
SizedBox(width: 8.0),
Expanded(

@ -27,42 +27,44 @@ class ListScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
String dateString = DateFormat.yMMMMd("en_US").format(DateTime.now());
final model = ScopedModel.of<AppState>(context, rebuildOnChange: true);
return CupertinoTabView(
builder: (context) {
String dateString = DateFormat.yMMMMd("en_US").format(DateTime.now());
final model = ScopedModel.of<AppState>(context, rebuildOnChange: true);
final rows = <Widget>[];
final rows = <Widget>[];
rows.add(
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 24.0, 16.0, 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(dateString.toUpperCase(), style: Styles.minorText),
Text('In season today', style: Styles.headlineText),
],
),
),
);
rows.add(
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 24.0, 16.0, 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(dateString.toUpperCase(), style: Styles.minorText),
Text('In season today', style: Styles.headlineText),
],
),
),
);
rows.addAll(_generateVeggieRows(model.availableVeggies));
rows.addAll(_generateVeggieRows(model.availableVeggies));
rows.add(
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 24.0, 16.0, 16.0),
child: Text('Not in season', style: Styles.headlineText),
),
);
rows.add(
Padding(
padding: const EdgeInsets.fromLTRB(16.0, 24.0, 16.0, 16.0),
child: Text('Not in season', style: Styles.headlineText),
),
);
rows.addAll(_generateVeggieRows(model.unavailableVeggies));
rows.addAll(_generateVeggieRows(model.unavailableVeggies));
return CupertinoTabView(
builder: (context) => DecoratedBox(
decoration: BoxDecoration(color: Color(0xffffffff)),
child: ListView(
children: rows,
),
return DecoratedBox(
decoration: BoxDecoration(color: Color(0xffffffff)),
child: ListView(
children: rows,
),
);
},
);
}
}

@ -7,13 +7,7 @@ import 'package:flutter/widgets.dart';
import 'package:veggieseasons/data/veggie.dart';
abstract class Styles {
static const baseTextStyle = TextStyle(
color: Color.fromRGBO(10, 10, 8, 1.0),
fontFamily: 'NotoSans',
fontSize: 16.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static String createHeroTag(Veggie veggie) => 'veggie_hero_${veggie.name}';
static const headlineText = TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.8),
@ -31,14 +25,6 @@ abstract class Styles {
fontWeight: FontWeight.bold,
);
static const bodyText = TextStyle(
color: Color.fromRGBO(240, 240, 240, 1.0),
fontFamily: 'NotoSans',
fontSize: 14.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static const minorText = TextStyle(
color: Color.fromRGBO(128, 128, 128, 1.0),
fontFamily: 'NotoSans',
@ -63,7 +49,7 @@ abstract class Styles {
fontWeight: FontWeight.normal,
);
static const seasonText = TextStyle(
static const activeSeasonText = TextStyle(
color: Color.fromRGBO(255, 255, 255, 0.9),
fontFamily: 'NotoSans',
fontSize: 24.0,
@ -71,6 +57,38 @@ abstract class Styles {
fontWeight: FontWeight.normal,
);
static const inactiveSeasonText = TextStyle(
color: Color.fromRGBO(80, 80, 80, 0.9),
fontFamily: 'NotoSans',
fontSize: 24.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static const cardTitleText = TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.9),
fontFamily: 'NotoSans',
fontSize: 32.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.bold,
);
static const cardCategoryText = TextStyle(
color: Color.fromRGBO(255, 255, 255, 0.9),
fontFamily: 'NotoSans',
fontSize: 16.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static const cardDescriptionText = TextStyle(
color: Color.fromRGBO(0, 0, 0, 0.9),
fontFamily: 'NotoSans',
fontSize: 16.0,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static const appBackground = Color(0xffd0d0d0);
static const scaffoldBackground = Color(0xfff0f0f0);
@ -128,4 +146,36 @@ abstract class Styles {
end: Alignment.bottomCenter,
colors: [transparentColor, shadowColor],
);
static const Color settingsMediumGray = Color(0xffc7c7c7);
static const Color settingsItemPressed = Color(0xffd9d9d9);
static const Color settingsLineation = Color(0xffbcbbc1);
static const Color settingsBackground = Color(0xffefeff4);
static const Color settingsGroupSubtitle = Color(0xff777777);
static const Color iconBlue = Color(0xff0000ff);
static const Color iconGold = Color(0xffdba800);
static const preferenceIcon = IconData(
0xf443,
fontFamily: CupertinoIcons.iconFont,
fontPackage: CupertinoIcons.iconFontPackage,
);
static const calorieIcon = IconData(
0xf3bb,
fontFamily: CupertinoIcons.iconFont,
fontPackage: CupertinoIcons.iconFontPackage,
);
static const checkIcon = IconData(
0xf383,
fontFamily: CupertinoIcons.iconFont,
fontPackage: CupertinoIcons.iconFontPackage,
);
}

@ -13,6 +13,7 @@ dependencies:
cupertino_icons: ^0.1.2
intl: ^0.15.7
scoped_model: ^0.3.0
shared_preferences: ^0.4.3
dev_dependencies:
flutter_test:

Loading…
Cancel
Save