mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Simplify image picking code
This commit is contained in:
		@@ -13,7 +13,10 @@ import 'package:comunic/utils/post_utils.dart';
 | 
			
		||||
import 'package:comunic/utils/ui_utils.dart';
 | 
			
		||||
import 'package:file_picker/file_picker.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:image_picker/image_picker.dart';
 | 
			
		||||
 | 
			
		||||
import '../../models/api_request.dart';
 | 
			
		||||
import '../../utils/log_utils.dart';
 | 
			
		||||
import '../../utils/ui_utils.dart';
 | 
			
		||||
 | 
			
		||||
/// Widget that allows to create posts
 | 
			
		||||
///
 | 
			
		||||
@@ -48,7 +51,7 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
 | 
			
		||||
  bool _isCreating = false;
 | 
			
		||||
  final TextEditingController _postTextController = TextEditingController();
 | 
			
		||||
  PostVisibilityLevel _postVisibilityLevel;
 | 
			
		||||
  PickedFile _postImage;
 | 
			
		||||
  BytesFile _postImage;
 | 
			
		||||
  String _postURL;
 | 
			
		||||
  List<int> _postPDF;
 | 
			
		||||
  DateTime _timeEnd;
 | 
			
		||||
@@ -239,15 +242,20 @@ class _PostCreateFormWidgetState extends State<PostCreateFormWidget> {
 | 
			
		||||
 | 
			
		||||
  /// Pick an image for the new post
 | 
			
		||||
  Future<void> _pickImageForPost() async {
 | 
			
		||||
    final image = await pickImage(context);
 | 
			
		||||
    try {
 | 
			
		||||
      final image = await pickImage(context);
 | 
			
		||||
 | 
			
		||||
    if (image == null) return;
 | 
			
		||||
      if (image == null) return;
 | 
			
		||||
 | 
			
		||||
    _resetPostSelection();
 | 
			
		||||
      _resetPostSelection();
 | 
			
		||||
 | 
			
		||||
    setState(() {
 | 
			
		||||
      this._postImage = image;
 | 
			
		||||
    });
 | 
			
		||||
      setState(() {
 | 
			
		||||
        this._postImage = image;
 | 
			
		||||
      });
 | 
			
		||||
    } catch (e, s) {
 | 
			
		||||
      logError(e, s);
 | 
			
		||||
      snack(context, tr("Failed to pick image for post!"));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Choose a new URL for the post
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user