Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
fix(anything dealing with jars): Refactor to store jars locally so th…
Browse files Browse the repository at this point in the history
…at the ui can utilize optimisti

BREAKING CHANGE: updated the workflow to use a Jar model rather than passing DocumentSnapshots
around

re #146
  • Loading branch information
Scott Clampet authored and Scott Clampet committed May 21, 2019
1 parent 05de5ef commit c8bea7a
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 100 deletions.
Binary file modified fude_app/ios/Runner.app.dSYM.zip
Binary file not shown.
Binary file modified fude_app/ios/Runner.ipa
Binary file not shown.
6 changes: 3 additions & 3 deletions fude_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 33;
CURRENT_PROJECT_VERSION = 34;
DEVELOPMENT_TEAM = R3D8JUT8KD;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -540,7 +540,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 33;
CURRENT_PROJECT_VERSION = 34;
DEVELOPMENT_TEAM = R3D8JUT8KD;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -566,7 +566,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 33;
CURRENT_PROJECT_VERSION = 34;
DEVELOPMENT_TEAM = R3D8JUT8KD;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
2 changes: 1 addition & 1 deletion fude_app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>33</string>
<string>34</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSPhotoLibraryUsageDescription</key>
Expand Down
12 changes: 6 additions & 6 deletions fude_app/ios/fastlane/report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@



<testcase classname="fastlane.lanes" name="0: update_fastlane" time="0.409673">
<testcase classname="fastlane.lanes" name="0: update_fastlane" time="0.349581">

</testcase>


<testcase classname="fastlane.lanes" name="1: default_platform" time="0.000964">
<testcase classname="fastlane.lanes" name="1: default_platform" time="0.001067">

</testcase>


<testcase classname="fastlane.lanes" name="2: increment_build_number" time="1.591999">
<testcase classname="fastlane.lanes" name="2: increment_build_number" time="1.245329">

</testcase>


<testcase classname="fastlane.lanes" name="3: get_provisioning_profile" time="2.855849">
<testcase classname="fastlane.lanes" name="3: get_provisioning_profile" time="4.501487">

</testcase>


<testcase classname="fastlane.lanes" name="4: build_app" time="353.561827">
<testcase classname="fastlane.lanes" name="4: build_app" time="254.330312">

</testcase>


<testcase classname="fastlane.lanes" name="5: upload_to_testflight" time="353.928109">
<testcase classname="fastlane.lanes" name="5: upload_to_testflight" time="364.547641">

</testcase>

Expand Down
1 change: 0 additions & 1 deletion fude_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:connectivity/connectivity.dart';

import 'package:fude/pages/auth/login/login.dart';
import 'package:fude/pages/auth/signup/signup.dart';
Expand Down
11 changes: 11 additions & 0 deletions fude_app/lib/models/jar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';

class Jar {
final String title;
final List<dynamic> categories;
final image;

Jar({@required this.title, this.categories, this.image});
}
43 changes: 8 additions & 35 deletions fude_app/lib/pages/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _HomePageState extends State<HomePage> {
setState(() {
internetConnection = false;
});
showInitialSnackBar();
showSnackBar();
print('No Connection: $val');
}
});
Expand All @@ -45,8 +45,7 @@ class _HomePageState extends State<HomePage> {
print('No Connection: $result');
}
});

widget.model.fetchAllUserJars(widget.model.currUserEmail);
widget.model.fetchAllUserJarsFromDB(widget.model.currUserEmail);
super.initState();
}

Expand All @@ -59,7 +58,7 @@ class _HomePageState extends State<HomePage> {
void _openJar(int index) async {
try {
await widget.model
.getJarBySelectedId(widget.model.usersJars[index].documentID);
.getJarBySelectedTitle(widget.model.usersJars[index].title);
Navigator.push(
context,
PageTransition(
Expand All @@ -73,46 +72,22 @@ class _HomePageState extends State<HomePage> {
}
}

void showInitialSnackBar() {
final String errorMsg = '''Poor Network Connection. Wait for a better connection, or try closing and reopening the app.
''';
final snackBar = SnackBar(
backgroundColor: Color.fromRGBO(255, 51, 74, 1),
elevation: 4,
content: Text(errorMsg,
style: TextStyle(color: Color.fromRGBO(242, 242, 242, 1))),
duration: Duration(seconds: 5),
);
mScaffoldState.currentState.showSnackBar(snackBar);
Timer(
Duration(seconds: 5),
() => setState(() {
internetConnection = true;
}));
}

void showSnackBar() {
final String errorMsg = '''
Poor Network Connection.
Wait for a better connection, or
try closing and reopening the app.
No Network Connection.
Reopen the app once you connect.
Some data may not show until you do.
''';
final snackBar = SnackBar(
backgroundColor: Color.fromRGBO(255, 51, 74, 1),
elevation: 4,
content: Text(errorMsg,
style: TextStyle(color: Color.fromRGBO(242, 242, 242, 1))),
action: SnackBarAction(
label: 'OK',
textColor: Color.fromRGBO(242, 242, 242, 1),
onPressed: () => setState(() {
internetConnection = true;
})),
duration: Duration(seconds: 5),
);
mScaffoldState.currentState.showSnackBar(snackBar);
Timer(
Duration(seconds: 5),
Duration(milliseconds: 5500),
() => setState(() {
internetConnection = true;
}));
Expand Down Expand Up @@ -179,9 +154,7 @@ class _HomePageState extends State<HomePage> {
mainAxisSize: MainAxisSize.max,
children: <Widget>[
widget.model.usersJars.length == 0
? Center(
child: CircularProgressIndicator(),
)
? Container()
: Container(
margin: EdgeInsets.fromLTRB(0, height * 0.1, 0, 0),
width: width,
Expand Down
56 changes: 35 additions & 21 deletions fude_app/lib/pages/home/home_page_jar.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
Expand All @@ -6,14 +8,14 @@ import 'package:page_transition/page_transition.dart';
import 'package:fude/scoped-models/main.dart';
import 'package:fude/pages/jars/jar_edit.dart';
import 'package:fude/pages/jars/jar_add.dart';
import 'package:fude/models/jar.dart';

class HomePageJar extends StatelessWidget {
final DocumentSnapshot jar;
final Jar jar;
final MainModel model;
final String title;

HomePageJar(
{@required this.model, this.jar, this.title});
HomePageJar({@required this.model, this.jar, this.title});

Widget _applyTextEffects({
@required double translationFactor,
Expand Down Expand Up @@ -44,7 +46,7 @@ class HomePageJar extends StatelessWidget {
width: width * 0.45,
// height: height * 0.1,
child: Text(
title == null ? jar['title'].toUpperCase() : 'ADD JAR',
title == null ? jar.title.toUpperCase() : 'ADD JAR',
overflow: TextOverflow.fade,
style: Theme.of(context).textTheme.subhead,
textAlign: TextAlign.left,
Expand Down Expand Up @@ -115,7 +117,7 @@ class HomePageJar extends StatelessWidget {
);
}),
Text(
title == null ? jar['title'].toUpperCase() : 'ADD JAR',
title == null ? jar.title.toUpperCase() : 'ADD JAR',
style: TextStyle(
color: model.darkTheme
? Color.fromRGBO(40, 40, 40, 1)
Expand All @@ -131,22 +133,34 @@ class HomePageJar extends StatelessWidget {

@override
Widget build(BuildContext context) {
// if(jar != null) {
// print(jar.data['title']);
// print(jar.data['image']);
// }
Image jarImage = Image(
image: jar != null
? jar.data['image'] != null
? NetworkImage(jar.data['image'])
: AssetImage('assets/logo.png')
: AssetImage('assets/logo.png'),
fit: BoxFit.cover,
alignment: FractionalOffset(
0.5,
0.5,
),
);
Image jarImage = jar != null
? jar.image.runtimeType != String && jar.image != null
? Image.file(
jar.image,
fit: BoxFit.cover,
alignment: FractionalOffset(
0.5,
0.5,
),
)
: Image(
image: jar.image != null
? NetworkImage(jar.image)
: AssetImage('assets/logo.png'),
fit: BoxFit.cover,
alignment: FractionalOffset(
0.5,
0.5,
),
)
: Image(
image: AssetImage('assets/logo.png'),
fit: BoxFit.cover,
alignment: FractionalOffset(
0.5,
0.5,
),
);
var image = title == null
? ClipRRect(
borderRadius: BorderRadius.circular(30.0),
Expand Down
4 changes: 1 addition & 3 deletions fude_app/lib/pages/jars/jar_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ class _JarPageState extends State<AddJarPage> {
return;
} else {
formKey.currentState.save(); // Save our form now.
print(_formData);
model.addJar(_formData);
Navigator.pop(context);
}
}

void updateTitle(String val) {
print('update title called: $_formData');
// print('update title called: $_formData');
if (val != null) {
setState(() {
_formData['title'] = val;
Expand Down Expand Up @@ -75,7 +74,6 @@ class _JarPageState extends State<AddJarPage> {
Widget build(BuildContext context) {
final double height = MediaQuery.of(context).size.height;
final double width = MediaQuery.of(context).size.width;
print('Building Jar_Add...');
return ScopedModelDescendant<MainModel>(
builder: (BuildContext context, Widget child, MainModel model) {
return Scaffold(
Expand Down
9 changes: 4 additions & 5 deletions fude_app/lib/pages/jars/jar_edit.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:page_transition/page_transition.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:scoped_model/scoped_model.dart';
Expand All @@ -8,11 +7,11 @@ import 'dart:io';
import 'package:fude/scoped-models/main.dart';
import 'package:fude/widgets/forms/edit_jar.dart';
import 'package:fude/widgets/forms/add_user_to_jar.dart';
import 'package:fude/pages/home/home.dart';
import 'package:fude/models/jar.dart';

class EditJarPage extends StatefulWidget {
final MainModel model;
final DocumentSnapshot jar;
final Jar jar;

EditJarPage({this.model, this.jar});
@override
Expand Down Expand Up @@ -40,7 +39,7 @@ class _JarPageState extends State<EditJarPage> {
@override
void initState() {
_waitingForJarData();
widget.model.getJarBySelectedId(widget.jar.documentID);
widget.model.getJarBySelectedTitle(widget.jar.title);
widget.model.resetIsLoading();
super.initState();
}
Expand Down Expand Up @@ -163,7 +162,7 @@ class _JarPageState extends State<EditJarPage> {
splashColor: Colors.transparent,
onPressed: () {
FocusScope.of(context).requestFocus(FocusNode());
model.fetchAllUserJars(model.currUserEmail);
model.fetchAllUserJarsFromDB(model.currUserEmail);
Navigator.pop(context);
}),
],
Expand Down
1 change: 0 additions & 1 deletion fude_app/lib/pages/jars/jar_notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class _JarNotesState extends State<JarNotes> {
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
// print('snapshot hasData: ${snapshot.hasData}');
return Center(child: CircularProgressIndicator());
} else {
return snapshot.data.documents.length > 0
Expand Down
Loading

0 comments on commit c8bea7a

Please sign in to comment.