Skip to content

Commit

Permalink
[#175 feat] : remove selected media files using their index (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alpha17-2 committed Jun 16, 2024
2 parents ee692ec + 5095e2a commit d307933
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 29 deletions.
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
errors:
must_be_immutable: ignore
include: package:flutter_lints/flutter.yaml

linter:
Expand Down
12 changes: 11 additions & 1 deletion lib/controllers/PostController/create_post_controller.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:wave/data/post_data.dart';
import 'package:wave/models/post_model.dart';
Expand Down Expand Up @@ -32,6 +33,15 @@ class CreatePostController extends ChangeNotifier {
notifyListeners();
}

void removeMediaFileAtIndex(int index) {
try {
selectedMediaFiles.removeAt(index);
notifyListeners();
} catch (e) {
"some exception occured $e".printError();
}
}

Future<CustomResponse> createNewPost(
{required String userId, String? caption}) async {
create_post = CREATE_POST.CREATING;
Expand All @@ -58,7 +68,7 @@ class CreatePostController extends ChangeNotifier {
await Database.postDatabase.doc(postId).update(post.toMap());
create_post = CREATE_POST.IDLE;
notifyListeners();
return CustomResponse(responseStatus: true,response: postId);
return CustomResponse(responseStatus: true, response: postId);
} on FirebaseException catch (e) {
create_post = CREATE_POST.IDLE;
notifyListeners();
Expand Down
23 changes: 9 additions & 14 deletions lib/view/reusable_components/custom_textbox_for_comment.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:wave/utils/constants/custom_colors.dart';
import 'package:wave/utils/constants/custom_icons.dart';
import 'package:wave/utils/device_size.dart';

import '../../utils/constants/custom_fonts.dart';

// ignore: must_be_immutable
Expand All @@ -13,7 +10,7 @@ class CustomTextBoxForComments extends StatelessWidget {
dynamic sendButtonMethod;
dynamic commentController;
String? imageUrl;

String? labelText;
String? errorText;
Widget? sendWidget;
Expand Down Expand Up @@ -42,22 +39,20 @@ class CustomTextBoxForComments extends StatelessWidget {
return Column(
children: [
Expanded(child: child!),
Divider(
const Divider(
height: 1,
),
header ?? SizedBox.shrink(),
header ?? const SizedBox.shrink(),
ListTile(
tileColor: backgroundColor,
leading: CircleAvatar(
radius: 20,
backgroundImage: (imageUrl != null &&
imageUrl!.isNotEmpty)
? CachedNetworkImageProvider(imageUrl!)
: null,
child: imageUrl == null ||
imageUrl!.isEmpty
? const Icon(Icons.person)
: null,
backgroundImage: (imageUrl != null && imageUrl!.isNotEmpty)
? CachedNetworkImageProvider(imageUrl!)
: null,
child: imageUrl == null || imageUrl!.isEmpty
? const Icon(Icons.person)
: null,
),
title: Form(
key: formKey,
Expand Down
2 changes: 1 addition & 1 deletion lib/view/reusable_components/mention_user_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MentionUserTile extends StatelessWidget {
style:
TextStyle(fontFamily: CustomFont.poppins, letterSpacing: 0.1),
),
SizedBox(
const SizedBox(
width: 2,
),
Visibility(
Expand Down
5 changes: 2 additions & 3 deletions lib/view/reusable_components/message_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:wave/models/message_model.dart';
import 'package:wave/models/user_model.dart';
import 'package:wave/utils/constants/custom_fonts.dart';
import 'package:wave/utils/constants/custom_icons.dart';

import 'package:wave/utils/device_size.dart';

Expand Down Expand Up @@ -57,15 +56,15 @@ class MessageContainer extends StatelessWidget {
? const Icon(Icons.person)
: null,
),
SizedBox(
const SizedBox(
width: 4,
),
Flexible(
child: Container(
constraints:
BoxConstraints(maxWidth: displayWidth(context) * 0.7),
decoration: BoxDecoration(
gradient: LinearGradient(
gradient: const LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
Expand Down
3 changes: 1 addition & 2 deletions lib/view/screens/ChatScreen/chat_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:wave/controllers/Authentication/user_controller.dart';
import 'package:wave/data/users_data.dart';
import 'package:wave/models/chat_model.dart';
import 'package:wave/models/user_model.dart';
import 'package:wave/utils/constants/custom_colors.dart';
import 'package:wave/utils/constants/custom_fonts.dart';
import 'package:wave/utils/constants/database_endpoints.dart';
import 'package:wave/utils/device_size.dart';
Expand Down Expand Up @@ -71,7 +70,7 @@ class ChatListScreen extends StatelessWidget {
)),
),
),
SizedBox(
const SizedBox(
height: 12,
),
Expanded(
Expand Down
28 changes: 25 additions & 3 deletions lib/view/screens/CreatePostScreen/add_image_for_post_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,31 @@ class AddImageForPostBox extends StatelessWidget {
return Padding(
padding:
const EdgeInsets.symmetric(horizontal: 4.0, vertical: 8),
child: file.path.endsWith('.mp4')
? VideoThumbnail(file: file)
: ImageThumbnail(file: file),
child: Stack(
children: [
file.path.endsWith('.mp4')
? VideoThumbnail(file: file)
: ImageThumbnail(file: file),
Positioned(
top: 0,
right: 0,
child: InkWell(
onTap: () {
postController.removeMediaFileAtIndex(index);
},
child: const CircleAvatar(
backgroundColor: Colors.white70,
radius: 11,
child: Icon(
Icons.close,
size: 15.4,
color: Colors.black,
),
),
),
)
],
),
);
},
)),
Expand Down
8 changes: 3 additions & 5 deletions lib/view/screens/SplashScreen/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import 'dart:async';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:wave/controllers/Authentication/user_controller.dart';
import 'package:wave/models/response_model.dart';
import 'package:wave/utils/constants/custom_fonts.dart';
import 'package:wave/utils/constants/cutom_logo.dart';
import 'package:wave/utils/constants/preferences.dart';
Expand Down Expand Up @@ -40,7 +38,7 @@ class _SplashScreenState extends State<SplashScreen> {
}

_navigateToLogin() async {
await Future.delayed(Duration(milliseconds: 3000), () {});
await Future.delayed(const Duration(milliseconds: 3000), () {});
Get.offNamed(AppRoutes.loginScreen);
}

Expand All @@ -56,7 +54,7 @@ class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xfbE30B5C),
backgroundColor: const Color(0xfbE30B5C),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -67,7 +65,7 @@ class _SplashScreenState extends State<SplashScreen> {
width: 200,
height: 200,
),
SizedBox(height: 30),
const SizedBox(height: 30),
Text(
'Wave',
style: TextStyle(
Expand Down

0 comments on commit d307933

Please sign in to comment.