Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ export_ipa/

# Avoid credentials
private_keys/
lib/src/api_keys.dart
ios/Runner/APIKey.plist

# Avoid python virtual environment
.venv/
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ocean_view
# CalCOFI OceanView

An app that incentivizes ocean goers to report their wild observations.

Expand All @@ -15,6 +15,12 @@ For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

### API Keys
Files with API keys are stored [here](https://drive.google.com/drive/folders/1KAYjrNAFgREmylkoRMiw6AwLAyZ0gwQy?usp=sharing). Please follow these steps to set up them accordingly.
1. Vision API: `api_keys.dart` needs to be put in `lib/src/api_keys.dart`.
2. Google Map API for Android: Copy `MAP_API_KEYS` in `local.properties` and paste it in `/android/local.properties`.
3. Google Map API for iOS: `APIKey.plist` needs to be put in `/ios/Runner/APIKey.plist`.

## Lint Code
- Please run `dart format .` in the project root folder everytime before pushing commits.
It will automatically lint the code to follow Dart guidelines.
Expand Down
10 changes: 8 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B9B4F200D14CA0402720FA0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7C1174BF10AEC556EB94460 /* Pods_Runner.framework */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
83F0EB9ACB7954BE38C9BC10 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3785899B6D83BF28E64390AE /* Pods_Runner.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
AC83416F29ADE80F00E395B7 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = AC83416E29ADE80F00E395B7 /* GoogleService-Info.plist */; };
AC9B2C612B4FC515009D168B /* APIKey.plist in Resources */ = {isa = PBXBuildFile; fileRef = AC9B2C602B4FC515009D168B /* APIKey.plist */; };
AC9B2C632B4FC7B2009D168B /* KeyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9B2C622B4FC7B2009D168B /* KeyManager.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -38,7 +39,6 @@
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
79F757806BA770C3C933E383 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
821ECB7493E4EDA0E715B203 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
Expand All @@ -49,6 +49,8 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AC83416E29ADE80F00E395B7 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
AC9B2C602B4FC515009D168B /* APIKey.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = APIKey.plist; sourceTree = "<group>"; };
AC9B2C622B4FC7B2009D168B /* KeyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManager.swift; sourceTree = "<group>"; };
BCFFB43291E209C69588D559 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
C2468002F99F9AFC852AF161 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -115,6 +117,8 @@
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
AC83416E29ADE80F00E395B7 /* GoogleService-Info.plist */,
AC9B2C602B4FC515009D168B /* APIKey.plist */,
AC9B2C622B4FC7B2009D168B /* KeyManager.swift */,
);
path = Runner;
sourceTree = "<group>";
Expand Down Expand Up @@ -197,6 +201,7 @@
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
AC83416F29ADE80F00E395B7 /* GoogleService-Info.plist in Resources */,
AC9B2C612B4FC515009D168B /* APIKey.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
Expand Down Expand Up @@ -300,6 +305,7 @@
files = (
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
AC9B2C632B4FC7B2009D168B /* KeyManager.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 4 additions & 2 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import GoogleMaps
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

// TODO: Add your API key
GMSServices.provideAPIKey("AIzaSyBpDLenOUhz8cWFT0Oc7gWD4MneSUboyVc")
// Add Google Map API key
if let APIKEY = KeyManager().getValue(key: "mapApiKey") as? String {
GMSServices.provideAPIKey(APIKEY)
}

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
17 changes: 17 additions & 0 deletions ios/Runner/KeyManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation
struct KeyManager {
private let keyFilePath = Bundle.main.path(forResource: "APIKey", ofType: "plist")
func getKeys() -> NSDictionary? {
guard let keyFilePath = keyFilePath else {
return nil
}
return NSDictionary(contentsOfFile: keyFilePath)
}

func getValue(key: String) -> AnyObject? {
guard let keys = getKeys() else {
return nil
}
return keys[key]! as AnyObject
}
}
2 changes: 2 additions & 0 deletions lib/models/observation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Observation {
int? confidentiality; // Share with scientists / Keep private / now int
int? confidence; // 1-3 can also be 0 for no confidence
String? url; // Url of photo on Firebase, generated when uploading
String? imagePath; // image path on Firebase Storage, generated when uploading
dynamic stopwatchStart; // Datetime of stopwatch start

Observation(
Expand All @@ -31,6 +32,7 @@ class Observation {
this.confidence,
this.status,
this.url,
this.imagePath,
this.stopwatchStart,
this.confidentiality});

Expand Down
2 changes: 1 addition & 1 deletion lib/screens/authenticate/register.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class _RegisterState extends State<Register> {
@override
Widget build(BuildContext context) {
return loading
? Loading()
? Loading('Registering...')
: Scaffold(
backgroundColor: topBarColor,
appBar: AppBar(
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/authenticate/sign_in.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _SignInState extends State<SignIn> {
@override
Widget build(BuildContext context) {
return loading
? Loading()
? Loading('Signing in...')
: Scaffold(
backgroundColor: topBarColor,
appBar: AppBar(
Expand Down
6 changes: 3 additions & 3 deletions lib/screens/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:ocean_view/models/userstats.dart';

import 'package:ocean_view/screens/map/map_page.dart';
import 'package:ocean_view/screens/upload/upload_page.dart';
import 'package:ocean_view/screens/activity_page.dart';
import 'package:ocean_view/screens/welcome_page.dart';
import 'package:ocean_view/screens/me/me_page.dart';
import 'package:ocean_view/screens/me/user_page.dart';
import 'package:ocean_view/services/auth.dart';
Expand Down Expand Up @@ -33,7 +33,7 @@ class _HomeState extends State<Home> {
List<Widget> _widgetOptions = <Widget>[
MapPage(key: UniqueKey()),
UploadPage(key: UniqueKey()),
ActivityPage(key: UniqueKey()),
WelcomePage(key: UniqueKey()),
UserPage(key: UniqueKey()),
MePage(key: UniqueKey()),
];
Expand Down Expand Up @@ -115,7 +115,7 @@ class _HomeState extends State<Home> {
), // This trailing comma makes auto-formatting nicer for build methods.
);
} else {
return Loading();
return Loading('Fetching user info...');
}
});
}
Expand Down
12 changes: 6 additions & 6 deletions lib/screens/me/me_observation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ class MeObservation extends StatelessWidget {
String state = await DatabaseService(uid: user!.uid)
.deleteObservation(this.observation);

if (state == 'Observation deleted') {
if (state == 'Unable to delete document') {
state = 'Unable to delete observation';
} else {
state = 'Observation deleted';
uStats?.numobs = uStats.numobs! - 1;
await DatabaseService(uid: user.uid)
.updateUserStats(uStats as UserStats);
final snackBar = SnackBar(content: Text(state));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
} else {
throw (state);
}

final snackBar = SnackBar(content: Text(state));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
// Back to previous page
Navigator.pop(context, ['Delete']);
},
Expand Down
Loading