Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FEAT(Stories): Integrate stories back-end #58

Merged
merged 7 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added analysis_report.json
Binary file not shown.
Binary file added analysis_report_after_fixing.json
Binary file not shown.
1 change: 1 addition & 0 deletions assets/tgs/laptop_devices_screen.tgs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/.env_example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ GITHUB_AUTH_URL=/auth/github

# mocking
USE_MOCK_DATA=true
USE_MOCK_DATA_STORIES=true
14 changes: 14 additions & 0 deletions lib/core/constants/keys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,19 @@ class Keys {
// SettingsScreen
static const settingsSetProfilePhotoOptions = ValueKey("set-profile-photo-option");

// CropImageScreen
static const refreshImageCropScreen = ValueKey('refresh_key');
static const zoomInImageCropScreen = ValueKey('zoom_in_key');
static const zoomOutImageCropScreen = ValueKey('zoom_out_key');
static const rotateLeftImageCropScreen = ValueKey('rotate_left_key');
static const rotateRightImageCropScreen = ValueKey('rotate_right_key');
static const popupMenuImageCropScreen = ValueKey('popup_menu_key');
static const popupMenuItemImageCropScreen = ValueKey('popup_menu_item_');
static const changeColorImageCropScreen = ValueKey('change_color_key');
static const submitCropImageCropScreen = ValueKey('submit_crop_key');

// Stories
static const storyAvatarPrefix = ValueKey('story_avatar_');

Keys._();
}
1 change: 1 addition & 0 deletions lib/core/mock/constants_mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';

final USE_MOCK_DATA = (dotenv.env['USE_MOCK_DATA'] ?? 'false') == 'true';
final USE_MOCK_DATA_STORIES = (dotenv.env['USE_MOCK_DATA_STORIES'] ?? 'true') == 'false';
3 changes: 2 additions & 1 deletion lib/features/auth/view/screens/log_in_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:telware_cross_platform/core/constants/keys.dart';
import 'package:vibration/vibration.dart';

import 'package:telware_cross_platform/core/providers/sign_up_provider.dart';
Expand All @@ -19,6 +18,8 @@ import 'package:telware_cross_platform/features/auth/view/widget/title_element.d
import 'package:telware_cross_platform/features/auth/view_model/auth_state.dart';
import 'package:telware_cross_platform/features/auth/view_model/auth_view_model.dart';

import '../../../../core/constants/keys.dart';

class LogInScreen extends ConsumerStatefulWidget {
static const String route = '/log-in';

Expand Down
2 changes: 1 addition & 1 deletion lib/features/chat/view/screens/create_chat_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:math';

import 'package:faker/faker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -300,6 +299,7 @@ class _CreateChatScreen extends ConsumerState<CreateChatScreen>
}

void filterView(String query) {

var filteredChats = <Map<String, dynamic>>[
{"options": <Map<String, dynamic>>[]}
];
Expand Down
3 changes: 2 additions & 1 deletion lib/features/chat/view/widget/chat_tile_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import 'package:go_router/go_router.dart';
import 'package:telware_cross_platform/core/constants/keys.dart';
import 'package:telware_cross_platform/core/models/chat_model.dart';
import 'package:telware_cross_platform/core/models/message_model.dart';
import 'package:telware_cross_platform/core/routes/routes.dart';
import 'package:telware_cross_platform/core/theme/palette.dart';
import 'package:telware_cross_platform/core/utils.dart';
import 'package:telware_cross_platform/features/chat/enum/chatting_enums.dart';
import 'package:telware_cross_platform/features/chat/enum/message_enums.dart';
import 'package:telware_cross_platform/features/user/view/widget/avatar_generator.dart';

import '../../../../core/routes/routes.dart';

class ChatTileWidget extends StatelessWidget {
const ChatTileWidget({
super.key,
Expand Down
2 changes: 0 additions & 2 deletions lib/features/chat/view/widget/message_tile_widget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
Expand Down Expand Up @@ -134,7 +133,6 @@ class MessageTileWidget extends StatelessWidget {
filePath: messageModel.content
?.toJson()["filePath"]))
: const SizedBox.shrink(),

// The timestamp is always in the bottom-right corner if there's space
Positioned(
bottom: 0,
Expand Down
11 changes: 11 additions & 0 deletions lib/features/stories/models/contact_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,15 @@ class ContactModel {
}
return hash;
}

factory ContactModel.fromJson(Map<String, dynamic> json) {
return ContactModel(
userId: json['userId'],
userName: json['name'],
userImageUrl: json['photo'],
stories: (json['stories'] as List<dynamic>)
.map((storyJson) => StoryModel.fromJson(storyJson))
.toList(),
);
}
}
13 changes: 13 additions & 0 deletions lib/features/stories/models/story_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,17 @@ class StoryModel {
storyCaption.hashCode ^
const ListEquality().hash(seenIds) ^
(storyContent?.hashCode ?? 0);

factory StoryModel.fromJson(Map<String, dynamic> json) {
return StoryModel(
storyId: json['_id'] ?? '',
isSeen: json['views'] != null && json['views'].isNotEmpty,
createdAt: DateTime.parse(json['timestamp'] ?? DateTime.now().toIso8601String()),
seenIds: (json['views'] as List<dynamic>?)?.map((e) => e.toString()).toList() ?? [],
storyContentType: 'image',
storyContentUrl: json['content'],
storyCaption: json['caption'] ?? '',
storyContent: null,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ class ContactsLocalRepository {
if (existingContact == null ||
contact != existingContact ||
existingContact.userImage == null) {
if (contact.userImage == null && existingContact?.userImage != null) {
return;
if (existingContact!= null &&
contact.userImage == null &&
existingContact.userImage != null &&
existingContact.userImageUrl == contact.userImageUrl) { //the difference is the existing has teh image bytes only
contact.userImage=existingContact.userImage;
}
await _saveContactImageInHive(contact);
}
Expand Down
Loading
Loading