This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| showFilePicker(FileType fileType) async { | |
| File file; | |
| if (fileType == FileType.IMAGE && SharedObjects.prefs.getBool(Constants.configImageCompression)) | |
| file = await ImagePicker.pickImage( | |
| source: ImageSource.gallery, imageQuality: 70); | |
| else | |
| file = await FilePicker.getFile(type: fileType); | |
| if (file == null) return; | |
| chatBloc.dispatch(SendAttachmentEvent(chat.chatId, file, fileType)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (event is ConfigValueChanged) { | |
| SharedObjects.prefs.setBool(event.key, event.value); | |
| yield ConfigChangeState(event.key, event.value); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| onChanged: (value) => configBloc.dispatch( | |
| ConfigValueChanged( | |
| Constants.configImageCompression, | |
| value)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @override | |
| Future<void> updateProfilePicture(String profilePictureUrl) async { | |
| String uid = SharedObjects.prefs.getString(Constants.sessionUid); | |
| DocumentReference ref = fireStoreDb.collection(Paths.usersPath).document( | |
| uid); //reference of the user's document node in database/users. This node is created using uid | |
| var data = { | |
| 'photoUrl': profilePictureUrl, | |
| }; | |
| await ref.setData(data, merge: true); // set the photourl | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UpdatingProfilePictureState extends ConfigState{} | |
| class ProfilePictureChangedState extends ConfigState{ | |
| final String profilePictureUrl; | |
| ProfilePictureChangedState(this.profilePictureUrl):super([profilePictureUrl]); | |
| @override | |
| String toString()=> 'ProfilePictureChangedState {profilePictureUrl: $profilePictureUrl}'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:equatable/equatable.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:meta/meta.dart'; | |
| @immutable | |
| abstract class ConfigState extends Equatable { | |
| ConfigState([List props = const <dynamic>[]]) : super(props); | |
| } | |
| class ConfigChangeState extends ConfigState{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UpdatingProfilePictureState extends ConfigState{} | |
| class ProfilePictureChangedState extends ConfigState{ | |
| final String profilePictureUrl; | |
| ProfilePictureChangedState(this.profilePictureUrl):super([profilePictureUrl]); | |
| @override | |
| String toString()=> 'ProfilePictureChangedState {profilePictureUrl: $profilePictureUrl}'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:async'; | |
| import 'package:bloc/bloc.dart'; | |
| import 'package:messio/config/Paths.dart'; | |
| import 'package:messio/repositories/StorageRepository.dart'; | |
| import 'package:messio/repositories/UserDataRepository.dart'; | |
| import 'package:messio/utils/SharedObjects.dart'; | |
| import 'Bloc.dart'; | |
| class ConfigBloc extends Bloc<ConfigEvent, ConfigState> { | |
| UserDataRepository userDataRepository; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UpdateProfilePicture extends ConfigEvent{ | |
| final File file; | |
| UpdateProfilePicture(this.file): super([file]); | |
| @override | |
| String toString() => 'UpdateProfilePicture'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Future pickImage() async { | |
| profileImageFile = await ImagePicker.pickImage(source: ImageSource.gallery); | |
| configBloc.dispatch(UpdateProfilePicture(profileImageFile)); | |
| } |