Skip to content

Commit

Permalink
finished
Browse files Browse the repository at this point in the history
  • Loading branch information
bamboo-wood committed Apr 10, 2023
1 parent cd9b3a7 commit 6dca979
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 31 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
80 changes: 56 additions & 24 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -602,26 +602,37 @@ PODS:
- BoringSSL-GRPC/Implementation (0.0.24):
- BoringSSL-GRPC/Interface (= 0.0.24)
- BoringSSL-GRPC/Interface (0.0.24)
- cloud_firestore (4.4.4):
- Firebase/Firestore (= 10.3.0)
- cloud_firestore (4.5.0):
- Firebase/Firestore (= 10.7.0)
- firebase_core
- Flutter
- nanopb (< 2.30910.0, >= 2.30908.0)
- Firebase/CoreOnly (10.3.0):
- FirebaseCore (= 10.3.0)
- Firebase/Firestore (10.3.0):
- Firebase/CoreOnly (10.7.0):
- FirebaseCore (= 10.7.0)
- Firebase/Firestore (10.7.0):
- Firebase/CoreOnly
- FirebaseFirestore (~> 10.3.0)
- firebase_core (2.7.1):
- Firebase/CoreOnly (= 10.3.0)
- FirebaseFirestore (~> 10.7.0)
- Firebase/Storage (10.7.0):
- Firebase/CoreOnly
- FirebaseStorage (~> 10.7.0)
- firebase_core (2.9.0):
- Firebase/CoreOnly (= 10.7.0)
- Flutter
- firebase_storage (11.1.0):
- Firebase/Storage (= 10.7.0)
- firebase_core
- Flutter
- FirebaseCore (10.3.0):
- FirebaseAppCheckInterop (10.7.0)
- FirebaseAuthInterop (10.7.0)
- FirebaseCore (10.7.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreInternal (10.5.0):
- FirebaseCoreExtension (10.7.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.7.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseFirestore (10.3.0):
- FirebaseFirestore (10.7.0):
- abseil/algorithm (~> 1.20211102.0)
- abseil/base (~> 1.20211102.0)
- abseil/container/flat_hash_map (~> 1.20211102.0)
Expand All @@ -634,12 +645,18 @@ PODS:
- "gRPC-C++ (~> 1.44.0)"
- leveldb-library (~> 1.22)
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseStorage (10.7.0):
- FirebaseAppCheckInterop (~> 10.0)
- FirebaseAuthInterop (~> 10.0)
- FirebaseCore (~> 10.0)
- FirebaseCoreExtension (~> 10.0)
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
- Flutter (1.0.0)
- GoogleUtilities/Environment (7.11.0):
- GoogleUtilities/Environment (7.11.1):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.0):
- GoogleUtilities/Logger (7.11.1):
- GoogleUtilities/Environment
- "GoogleUtilities/NSData+zlib (7.11.0)"
- "GoogleUtilities/NSData+zlib (7.11.1)"
- "gRPC-C++ (1.44.0)":
- "gRPC-C++/Implementation (= 1.44.0)"
- "gRPC-C++/Interface (= 1.44.0)"
Expand Down Expand Up @@ -691,9 +708,10 @@ PODS:
- gRPC-Core/Interface (= 1.44.0)
- Libuv-gRPC (= 0.0.10)
- gRPC-Core/Interface (1.44.0)
- GTMSessionFetcher/Core (3.1.0)
- image_picker_ios (0.0.1):
- Flutter
- leveldb-library (1.22.1)
- leveldb-library (1.22.2)
- Libuv-gRPC (0.0.10):
- Libuv-gRPC/Implementation (= 0.0.10)
- Libuv-gRPC/Interface (= 0.0.10)
Expand All @@ -713,6 +731,7 @@ PODS:
DEPENDENCIES:
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_storage (from `.symlinks/plugins/firebase_storage/ios`)
- Flutter (from `Flutter`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
Expand All @@ -722,12 +741,17 @@ SPEC REPOS:
- abseil
- BoringSSL-GRPC
- Firebase
- FirebaseAppCheckInterop
- FirebaseAuthInterop
- FirebaseCore
- FirebaseCoreExtension
- FirebaseCoreInternal
- FirebaseFirestore
- FirebaseStorage
- GoogleUtilities
- "gRPC-C++"
- gRPC-Core
- GTMSessionFetcher
- leveldb-library
- Libuv-gRPC
- nanopb
Expand All @@ -738,6 +762,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/cloud_firestore/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_storage:
:path: ".symlinks/plugins/firebase_storage/ios"
Flutter:
:path: Flutter
image_picker_ios:
Expand All @@ -748,23 +774,29 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
abseil: ebe5b5529fb05d93a8bdb7951607be08b7fa71bc
BoringSSL-GRPC: 3175b25143e648463a56daeaaa499c6cb86dad33
cloud_firestore: 612a89fe1210990e2ba642b850e8faf7d393eedd
Firebase: f92fc551ead69c94168d36c2b26188263860acd9
firebase_core: 1ae9f9aa76e6e1edc14fb181637ad466fd6c6fa4
FirebaseCore: 988754646ab3bd4bdcb740f1bfe26b9f6c0d5f2a
FirebaseCoreInternal: e463f41bb935cd049505bf7e9a5bdd7dcea90df6
FirebaseFirestore: 244f71ff14ef44f39e00b44d356eac708ce03103
cloud_firestore: 84f58b426bd8d21a22c4b19d9d18028fc4ff3eb1
Firebase: 0219acf760880eeec8ce479895bd7767466d9f81
firebase_core: d85432877e814811e040e7659f9c82faeab66e04
firebase_storage: 3419feab3ca832a07bdff5307477e0b9d20eb5f8
FirebaseAppCheckInterop: 8e907eea79958960a8bd2058e067f31e03a7914b
FirebaseAuthInterop: 46201190fe90ef1f581513eb0f9fa3d7820e7d6d
FirebaseCore: e317665b9d744727a97e623edbbed009320afdd7
FirebaseCoreExtension: f17247ba8c61e4d3c8d136b5e2de3cb4ac6a85b6
FirebaseCoreInternal: 8845798510aae74703467480f71ac613788d0696
FirebaseFirestore: 3963a6edd1c84b4748dab3e2c62624a29d03eca1
FirebaseStorage: 4841efa304543e1f9e4ca116c559c7a1ea2a9d0f
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
GoogleUtilities: c2bdc4cf2ce786c4d2e6b3bcfd599a25ca78f06f
GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749
"gRPC-C++": 9675f953ace2b3de7c506039d77be1f2e77a8db2
gRPC-Core: 943e491cb0d45598b0b0eb9e910c88080369290b
GTMSessionFetcher: c9e714f7eec91a55641e2bab9f45fd83a219b882
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
leveldb-library: 50c7b45cbd7bf543c81a468fe557a16ae3db8729
leveldb-library: f03246171cce0484482ec291f88b6d563699ee06
Libuv-gRPC: 55e51798e14ef436ad9bc45d12d43b77b49df378
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

COCOAPODS: 1.12.0
14 changes: 14 additions & 0 deletions lib/firestore/user_firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,18 @@ class UserFirestore {
return null;
}
}

static Future<void> updateUser(User newProfile) async {
try {
await _userCollection.doc(newProfile.uid).update(
{
'name': newProfile.name,
'imagePath': newProfile.imagePath,
},
);
} catch (e) {
print('Failed to update user information.');
print('$e');
}
}
}
27 changes: 21 additions & 6 deletions lib/pages/setting_profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import 'dart:io';

import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_firebase_chat_app/firestore/user_firestore.dart';
import 'package:flutter_firebase_chat_app/utils/shared_prefs.dart';
import 'package:image_picker/image_picker.dart';

import '../model/user.dart';

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

Expand All @@ -16,6 +20,8 @@ class _SettingProfilePageState extends State<SettingProfilePage> {
final ImagePicker _picker = ImagePicker();
String imagePath = '';

final TextEditingController _nameController = TextEditingController();

Future<void> selectImage() async {
final XFile? pickedFile = await _picker.pickImage(source: ImageSource.gallery);
if (pickedFile != null) {
Expand All @@ -26,7 +32,8 @@ class _SettingProfilePageState extends State<SettingProfilePage> {
}

Future<void> uploadImage() async {
final ref = FirebaseStorage.instance.ref().child('profileImage').child('profileImage.jpg');
String path = image!.path.substring(image!.path.lastIndexOf('/') + 1, image!.path.length);
final ref = FirebaseStorage.instance.ref().child('profileImage').child(path);
final storedImage = await ref.putFile(image!);
imagePath = await storedImage.ref.getDownloadURL();
}
Expand All @@ -42,12 +49,16 @@ class _SettingProfilePageState extends State<SettingProfilePage> {
child: Column(
children: [
Row(
children: const [
SizedBox(
children: [
const SizedBox(
width: 100,
child: Text('Name'),
),
Expanded(child: TextField()),
Expanded(
child: TextField(
controller: _nameController,
),
),
],
),
const SizedBox(height: 50),
Expand Down Expand Up @@ -90,8 +101,12 @@ class _SettingProfilePageState extends State<SettingProfilePage> {
width: 200,
height: 50,
child: ElevatedButton(
onPressed: () {
//
onPressed: () async {
User newProfile = User(
name: _nameController.text,
imagePath: imagePath,
uid: SharedPrefs.fetchUid()!);
await UserFirestore.updateUser(newProfile);
},
child: const Text('Submit'),
),
Expand Down

0 comments on commit 6dca979

Please sign in to comment.