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

Changed the gallery option to camera uploads #1

Merged
merged 8 commits into from
Jul 20, 2023
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/flutter_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ jobs:
channel: stable
- run: flutter pub get
- run: flutter analyze
- run: flutter test
7 changes: 4 additions & 3 deletions lib/capture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class _CaptureState extends State<Capture> {
// Open camera or gallery
ImagePicker imagePicker = ImagePicker();
XFile? file =
await imagePicker.pickImage(source: ImageSource.gallery);
print('${file?.path}');
await imagePicker.pickImage(source: ImageSource.camera);
//print('${file?.path}');
if (file == null) return;

// Create unique file name
Expand All @@ -71,13 +71,14 @@ class _CaptureState extends State<Capture> {
content: Text(
'Description and Image added successfully\n\t\t\t\tNow Press Submit Button'),
);
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(context).showSnackBar(snackBar);
try {
// Store the file
await referenceImageToUpload.putFile(File(file.path));
imageUrl = await referenceImageToUpload.getDownloadURL();
} catch (error) {
print(error);
// print(error);
}
},
),
Expand Down
5 changes: 3 additions & 2 deletions lib/createhike.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:open_street_map_search_and_pick/open_street_map_search_and_pick.dart';

class CreateHike extends StatefulWidget {
// ignore: use_key_in_widget_constructors
const CreateHike({Key? key});

@override
Expand Down Expand Up @@ -153,7 +154,7 @@ class _CreateHikeState extends State<CreateHike> {

Future<void> _submitData() async {
if (startLocation == null || endLocation == null || date == null) {
print('Please fill all the fields');
//print('Please fill all the fields');
return;
}

Expand All @@ -166,7 +167,7 @@ class _CreateHikeState extends State<CreateHike> {
// Data saved successfully, show success message or navigate to the next screen
} catch (error) {
// Handle error, show error message or retry logic
print('Error saving data: $error');
// print('Error saving data: $error');
}
}
}
10 changes: 5 additions & 5 deletions lib/description.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Description extends StatelessWidget {
final String placeName;
final String description;

Description({
const Description({
Key? key,
required this.imageUrl,
required this.placeName,
Expand All @@ -19,7 +19,7 @@ class Description extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Description"),
title: const Text("Description"),
),
body: SingleChildScrollView(
child: Column(
Expand Down Expand Up @@ -57,7 +57,7 @@ class Description extends StatelessWidget {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MyHome()),
MaterialPageRoute(builder: (context) => const MyHome()),
);
},
),
Expand All @@ -67,7 +67,7 @@ class Description extends StatelessWidget {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Group()),
MaterialPageRoute(builder: (context) => const Group()),
);
},
),
Expand All @@ -79,7 +79,7 @@ class Description extends StatelessWidget {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Capture()),
MaterialPageRoute(builder: (context) => const Capture()),
);
},
),
Expand Down
7 changes: 4 additions & 3 deletions lib/group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:trips1/createhike.dart';
import 'package:trips1/join.dart';

class Group extends StatefulWidget {
// ignore: use_key_in_widget_constructors
const Group({Key? key});

@override
Expand Down Expand Up @@ -58,9 +59,9 @@ class _GroupState extends State<Group> {
buttonColor: Colors.blue,
buttonText: 'Set Current Location',
onPicked: (pickedData) {
print(pickedData.latLong.latitude);
print(pickedData.latLong.longitude);
print(pickedData.address);
// print(pickedData.latLong.latitude);
// print(pickedData.latLong.longitude);
// print(pickedData.address);
},
),
),
Expand Down
48 changes: 13 additions & 35 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import 'package:flutter/material.dart';
import 'package:trips1/description.dart';
import 'package:trips1/group.dart';
import 'capture.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class MyHome extends StatefulWidget {
const MyHome({super.key});

@override
State<MyHome> createState() => _MyHomeState();
}

class _MyHomeState extends State<MyHome> {
String imageUrl = '';
final FirebaseStorage _storage = FirebaseStorage.instance;
// final FirebaseStorage _storage = FirebaseStorage.instance;
final CollectionReference _placesReference =
FirebaseFirestore.instance.collection('places');
final CollectionReference _cultural =
Expand All @@ -29,16 +30,16 @@ class _MyHomeState extends State<MyHome> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
const Padding(
padding: EdgeInsets.fromLTRB(
16, 40, 16, 8), // Adjust padding as needed
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(
SizedBox(
width: 30,
),
const CircleAvatar(
CircleAvatar(
backgroundImage: AssetImage('assets/register.png'),
),
],
Expand Down Expand Up @@ -94,7 +95,7 @@ class _MyHomeState extends State<MyHome> {
height: 30,
),
const Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Places and Descriptions',
style: TextStyle(
Expand All @@ -106,7 +107,7 @@ class _MyHomeState extends State<MyHome> {
),
const SizedBox(height: 10),

Container(
SizedBox(
height: 200,
child: FutureBuilder<QuerySnapshot>(
future: _placesReference.get(),
Expand Down Expand Up @@ -173,7 +174,7 @@ class _MyHomeState extends State<MyHome> {
),
),
const SizedBox(height: 10),
Container(
SizedBox(
height: 200,
child: FutureBuilder<QuerySnapshot>(
future: _cultural.get(),
Expand Down Expand Up @@ -243,7 +244,7 @@ class _MyHomeState extends State<MyHome> {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MyHome()),
MaterialPageRoute(builder: (context) => const MyHome()),
);
},
),
Expand All @@ -253,7 +254,7 @@ class _MyHomeState extends State<MyHome> {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Group()),
MaterialPageRoute(builder: (context) => const Group()),
);
},
),
Expand All @@ -265,7 +266,7 @@ class _MyHomeState extends State<MyHome> {
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Capture()),
MaterialPageRoute(builder: (context) => const Capture()),
);
},
),
Expand All @@ -274,27 +275,4 @@ class _MyHomeState extends State<MyHome> {
),
);
}

Widget _buildGroupItem(String imagePath, String title) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 15, vertical: 6),
height: 250,
width: 200,
child: Expanded(
// Adjust the height as needed
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Image.asset(imagePath),
Text(
title,
style: const TextStyle(fontSize: 16, color: Colors.white),
),
],
),
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/join.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class _JoinState extends State<Join> {
child: ListTile(
title: Text(
'Start Location: $startLocation',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
12 changes: 7 additions & 5 deletions lib/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class MyLogin extends StatefulWidget {
}

class _MyLoginState extends State<MyLogin> {
// ignore: unused_element
Future<FirebaseApp> _initializeFirebase() async {
FirebaseApp firebaseApp = await Firebase.initializeApp();
return firebaseApp;
}
//final FirebaseAuth _auth = FirebaseAuth.instance;

// Function to handle sign in
// ignore: unused_element
static Future<User?> _signInWithEmailAndPassword(
{required String email,
required String password,
Expand All @@ -34,13 +36,13 @@ class _MyLoginState extends State<MyLogin> {
user = userCredential.user;
} on FirebaseAuthException catch (e) {
if (e.code == "user-not-found") {
print("No User found for that email");
// print("No User found for that email");
} else if (e.code == "wrong-password") {
print("Wrong password provided for that user");
//print("Wrong password provided for that user");
} else if (e.code == "invalid-email") {
print("Invalid email address");
//print("Invalid email address");
} else {
print(e.code);
//print(e.code);
}
// Handle sign in error here
}
Expand Down Expand Up @@ -124,13 +126,13 @@ class _MyLoginState extends State<MyLogin> {
}
}
},
child: Text('SIGN IN'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(
horizontal: 50, vertical: 10),
textStyle: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold)),
child: const Text('SIGN IN'),
),
const SizedBox(
height: 20,
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() async {
routes: {
'login': (context) => const MyLogin(),
'register': (context) => const MyRegister(),
'home': (context) => MyHome(),
'home': (context) => const MyHome(),
},
));
}
8 changes: 4 additions & 4 deletions lib/register.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MyRegister extends StatelessWidget {
body: Stack(
children: [
Container(
padding: EdgeInsets.only(left: 35, top: 130),
padding: const EdgeInsets.only(left: 35, top: 130),
child: const Text(
"SIGN UP",
style: TextStyle(color: Colors.white, fontSize: 30),
Expand Down Expand Up @@ -98,16 +98,16 @@ class MyRegister extends StatelessWidget {
// print('The account already exists for that email.');
}
} catch (e) {
print(e);
//print(e);
}
},
child: Text('SIGN UP'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(
horizontal: 50, vertical: 10),
textStyle: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold)),
child: const Text('SIGN UP'),
),
const SizedBox(
height: 20,
Expand All @@ -120,13 +120,13 @@ class MyRegister extends StatelessWidget {
onPressed: () {
Navigator.pushNamed(context, 'login');
},
child: Text('SIGN IN'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(
horizontal: 50, vertical: 10),
textStyle: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold)),
child: const Text('SIGN IN'),
),
]),
),
Expand Down
Loading
Loading