Skip to content

Commit

Permalink
Fixes Tracking issue , add Dynamic Data in Screens , created AddPet File
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzail-Raza committed May 7, 2024
1 parent 4ad9c4c commit 2f1ee79
Show file tree
Hide file tree
Showing 15 changed files with 681 additions and 35 deletions.

Large diffs are not rendered by default.

Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pet_care/.flutter-plugins-dependencies

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion pet_care/lib/CommunityTestScreen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:math';

import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -85,14 +86,23 @@ class _CommunityScreenState extends State<CommunityScreen> {
);
}

// Todo Fix The Naming of File

String randomString(int length) {
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
final random = Random();
return String.fromCharCodes(Iterable.generate(
length, (_) => chars.codeUnitAt(random.nextInt(chars.length))));
}

pickImage(ImageSource imageSource) async {
try {
final photo = await ImagePicker().pickImage(source: imageSource);
if (photo == null) {
return;
}
final tempImage = File(photo.path);
var url = await DataBase.sendImage("CommunityMessagesPics", tempImage);
var url = await DataBase.uploadImage(randomString(12),"CommunityMessagesPics", tempImage);

// Todo try to remove url exrtra space

Expand Down
7 changes: 6 additions & 1 deletion pet_care/lib/GoogleNavBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:pet_care/CommunityScreen.dart';
import 'package:pet_care/CommunityTestScreen.dart';
import 'package:pet_care/ProfilePage.dart';
import 'package:pet_care/TrackingPet.dart';
import 'package:pet_care/addPetDyanamic.dart';
import 'package:pet_care/addPetForm.dart';
import 'package:pet_care/petScreen.dart';

class Tests extends StatefulWidget {
Expand All @@ -23,6 +25,7 @@ class _TestsState extends State<Tests> {

List<Widget> _screens = <Widget>[
petScreen(userData: {},),
// addPetForm(userData: {},),
Container(
color: Colors.blue,
),
Expand All @@ -42,7 +45,9 @@ class _TestsState extends State<Tests> {
Name = Name.substring(0, 11);
}
super.initState();
_screens[0]=petScreen(userData: widget.userData);
// _screens[0]=petScreen(userData: widget.userData);
_screens[0]=petScreenDynamic(userData: widget.userData);
// _screens[0] = addPetForm(userData: widget.userData,);
_screens[3] = ProfilePage(userData: widget.userData);
_screens[4] = CommunityScreen(
userData: {
Expand Down
10 changes: 6 additions & 4 deletions pet_care/lib/PetDetailsWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import 'package:pet_care/showTaskDetailsContainer.dart';
import 'package:pet_care/uihelper.dart';

class PetDetailsWidget extends StatefulWidget {
const PetDetailsWidget({super.key});
Map<String,dynamic> ?petData;

PetDetailsWidget({super.key,required this.petData});

@override
State<PetDetailsWidget> createState() => _PetDetailsWidgetState();
Expand Down Expand Up @@ -41,7 +43,7 @@ class _PetDetailsWidgetState extends State<PetDetailsWidget> {
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage:
AssetImage("assets/images/petPic.png"),
NetworkImage(widget.petData!["Photo"]),
radius: 78,
),
),
Expand All @@ -52,15 +54,15 @@ class _PetDetailsWidgetState extends State<PetDetailsWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Jerry",
widget.petData!["Name"],
style: TextStyle(
fontSize: headingFont-3,
fontWeight: FontWeight.w400),
),
Padding(
padding: const EdgeInsets.only(left: 3),
child: Text(
"My Lovely Pet ! ",
widget.petData!["Breed"],
style: TextStyle(
fontSize: subHeadingFont-3,
fontWeight: FontWeight.w300),
Expand Down
43 changes: 23 additions & 20 deletions pet_care/lib/TrackingPet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,31 +145,34 @@ class _trackingPetState extends State<trackingPet> {
// Todo Solve this error
uiHelper.customAlertBox(() {}, context, "Located2 $_permissionGuranted");
if (_permissionGuranted == PermissionStatus.denied) {
uiHelper.customAlertBox(() {}, context, "Located2");
uiHelper.customAlertBox(() {}, context, "Located2 Inner 1 $_permissionGuranted");

_permissionGuranted = await _locationController.requestPermission();
await uiHelper.customAlertBox(() {}, context, "Located2 Inner 2 $_permissionGuranted");
if (_permissionGuranted != PermissionStatus.granted) {
await uiHelper.customAlertBox(() {}, context, "Located2 Inner Blocked Block $_permissionGuranted");
return;
}
} else {
_locationController.onLocationChanged
.listen((LocationData currentLocation) {
if (currentLocation.latitude != null &&
currentLocation.longitude != null) {
setState(() {
_current =
LatLng(currentLocation.latitude!, currentLocation.longitude!);
// pos=LatLng(pos.latitude + 0.0000052, pos.longitude + 0.000058) ;
print("Location : $_current");
print("Location : $pos");
print(polylineCoordinates);
if(isRouting) {
reFocus(_current!);
}
// uiHelper.customAlertBox(() { }, context, "Located");
});
}
});
else {
uiHelper.customAlertBox(() {}, context, "Located2 Final Block");
_locationController.onLocationChanged
.listen((LocationData currentLocation) {
if (currentLocation.latitude != null &&
currentLocation.longitude != null) {
setState(() {
_current = LatLng(currentLocation.latitude!, currentLocation.longitude!);
// pos=LatLng(pos.latitude + 0.0000052, pos.longitude + 0.000058) ;
print("Location : $_current");
print("Location : $pos");
print(polylineCoordinates);
if(isRouting) {
reFocus(_current!);
}
// uiHelper.customAlertBox(() { }, context, "Located");
});
}
});
}
}
}

Expand Down
114 changes: 114 additions & 0 deletions pet_care/lib/addPetDyanamic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:pet_care/petDetails.dart';
import 'package:pet_care/uihelper.dart';

class petScreenDynamic extends StatefulWidget {
Map<String,dynamic> userData;
petScreenDynamic({super.key,required this.userData});

@override
State<petScreenDynamic> createState() => _petScreenDynamicState();
}

class _petScreenDynamicState extends State<petScreenDynamic> {

@override
Widget build(BuildContext context) {
return Stack(children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
color: Colors.pinkAccent.shade100,
borderRadius: BorderRadius.circular(10)),
),
),
Container(
decoration: BoxDecoration(
color: Colors.white70,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(color: Colors.transparent),
child: StreamBuilder(
stream: FirebaseFirestore.instance
.collection("PetData")
.doc(widget.userData["Email"]+"1")
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
if (!snapshot.requireData.exists) {
return Center(
child: Container(
width: RenderErrorBox.minimumWidth,
height: RenderErrorBox.minimumWidth / 1.5,
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(10),
border:
Border.all(color: Colors.pinkAccent.shade200)),
child: Center(
child: Text(
"Error ${snapshot.error.toString()}",
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
)),
),
);
} else if (snapshot.hasData) {
// print("Snap Data : ${snapshot.data.toString()}");
// Todo setList Info

// list = snapshot.data!["petIds"];
return ListView.builder(
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.all(20.0),
child: InkWell(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => petDetails(petData: snapshot.data!.data(),),));
},
child: Container(
decoration: BoxDecoration(
color: Colors.pinkAccent.shade100,
borderRadius: BorderRadius.circular(13)),
child: ListTile(
style: ListTileStyle.drawer,
leading: CircleAvatar(
backgroundImage: NetworkImage(snapshot.data!["Photo"])),
contentPadding: EdgeInsets.all(30),
title: Text(
"${snapshot.data!["Name"]} + $index"),
subtitle: Text(
"${snapshot.data!["Breed"]} "),
trailing: Icon(
Icons.ads_click,
color: Colors.pinkAccent.shade700,
),
),
),
),
);
},

// Todo Fix The Iterator lenght
itemCount: 1,
);
}
}

return Center(
child: CircularProgressIndicator(),
);
}),
),
)
]);
}
}
Loading

0 comments on commit 2f1ee79

Please sign in to comment.