Skip to content

Commit

Permalink
chore: fixed AbortController issue on logOut; add `newAvatarImage…
Browse files Browse the repository at this point in the history
…Text` l10n; add `/` directory to `dependabot`.
  • Loading branch information
itsezlife committed Mar 24, 2024
1 parent 23a61cd commit 9a599d6
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 45 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ updates:
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "pub"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "pub"
directory: "/packages/app_ui"
schedule:
Expand Down
1 change: 1 addition & 0 deletions lib/app/view/app_init_utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void initUtilities(BuildContext context, Locale locale) {
notFoundingCameraText: l10n.notFoundingCameraText,
noCameraFoundText: l10n.noCameraFoundText,
newPostText: l10n.newPostText,
newAvatarImageText: l10n.newAvatarImageText,
),
);
BlockSettings().init(
Expand Down
3 changes: 2 additions & 1 deletion lib/auth/cubit/manage_password_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class ManagePasswordCubit extends Cubit<bool> {
/// {@macro manage_password_cubit}
ManagePasswordCubit() : super(true);

/// Defines method to change screen from forgot to change password or reversed.
/// Defines method to change screen from forgot to change password or
/// reversed.
void changeScreen({required bool showForgotPassword}) =>
emit(showForgotPassword);
}
8 changes: 4 additions & 4 deletions lib/auth/signup/cubit/sign_up_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'dart:io';

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:firebase_notifications_client/firebase_notifications_client.dart';
import 'package:form_fields/form_fields.dart';
import 'package:notifications_repository/notifications_repository.dart';
import 'package:powersync_repository/powersync_repository.dart';
import 'package:shared/shared.dart';
import 'package:user_repository/user_repository.dart';
Expand All @@ -19,13 +19,13 @@ class SignUpCubit extends Cubit<SignupState> {
/// {@macro sign_up_cubit}
SignUpCubit({
required UserRepository userRepository,
required FirebaseNotificationsClient notificationsClient,
required NotificationsRepository notificationsRepository,
}) : _userRepository = userRepository,
_notificationsClient = notificationsClient,
_notificationsClient = notificationsRepository,
super(const SignupState.initial());

final UserRepository _userRepository;
final FirebaseNotificationsClient _notificationsClient;
final NotificationsRepository _notificationsClient;

/// Changes password visibility, making it visible or not.
void changePasswordVisibility() => emit(
Expand Down
4 changes: 2 additions & 2 deletions lib/auth/signup/view/sign_up_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:firebase_notifications_client/firebase_notifications_client.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_instagram_offline_first_clone/auth/signup/cubit/sign_up_cubit.dart';
import 'package:flutter_instagram_offline_first_clone/auth/signup/view/view.dart';
import 'package:notifications_repository/notifications_repository.dart';
import 'package:user_repository/user_repository.dart';

class SignupPage extends StatelessWidget {
Expand All @@ -13,7 +13,7 @@ class SignupPage extends StatelessWidget {
return BlocProvider(
create: (context) => SignUpCubit(
userRepository: context.read<UserRepository>(),
notificationsClient: context.read<FirebaseNotificationsClient>(),
notificationsRepository: context.read<NotificationsRepository>(),
),
child: const SignupView(),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/chats/widgets/fun.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FunView extends StatelessWidget {
],
),
),
const SliverToBoxAdapter(child: Gap.v(AppSpacing.md)),
const SliverGap.v(AppSpacing.md),
SeparatedContainer(
onlyTop: true,
child: Row(
Expand Down Expand Up @@ -90,7 +90,7 @@ class FunView extends StatelessWidget {
],
),
),
const SliverToBoxAdapter(child: Gap.v(AppSpacing.md)),
const SliverGap.v(AppSpacing.md),
SeparatedContainer(
onlyTop: true,
child: Column(
Expand Down
2 changes: 1 addition & 1 deletion lib/feed/post/widgets/share_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class SearchAppBar extends StatelessWidget implements PreferredSizeWidget {
? <User>[]
: followersAndFollowings
.where(
(user) => user.username!
(user) => user.displayUsername
.toLowerCase()
.trim()
.contains(query.toLowerCase().trim()),
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
}
},
"newPostText": "New post",
"newAvatarImageText": "New avatar image",
"writeCaptionText": "Write caption...",
"logOutText": "Log out",
"logOutConfirmationText": "Are you sure you want to log out?",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/arb/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
}
},
"newPostText": "Новая публикация",
"newAvatarImageText": "Новое фото аватара",
"writeCaptionText": "Добавить подпись...",
"logOutText": "Выйти",
"logOutConfirmationText": "Вы уверены что хотите выйти из аккаунта?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,9 @@ class SupabaseAuthenticationClient implements AuthenticationClient {
@override
Future<void> logOut() async {
try {
await Future.wait([
_powerSyncRepository.supabase.auth.signOut(),
_powerSyncRepository.db().disconnectAndClear(),
_googleSignIn.signOut(),
]);
await _powerSyncRepository.db().disconnectAndClear();
await _powerSyncRepository.supabase.auth.signOut();
await _googleSignIn.signOut();
} catch (error, stackTrace) {
Error.throwWithStackTrace(LogOutFailure(error), stackTrace);
}
Expand Down
10 changes: 6 additions & 4 deletions packages/database_client/lib/src/database_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ SELECT
c1.*,
p.avatar_url as avatar_url,
p.username as username,
p.full_name as full_name,
COUNT(c2.id) AS replies
FROM
comments c1
Expand All @@ -886,7 +887,7 @@ FROM
WHERE
c1.post_id = ? AND c1.replied_to_comment_id IS NULL
GROUP BY
c1.id, p.avatar_url, p.username
c1.id, p.avatar_url, p.username, p.full_name
ORDER BY created_at ASC
''',
parameters: [postId],
Expand Down Expand Up @@ -1031,15 +1032,16 @@ insert into
SELECT
c1.*,
p.avatar_url as avatar_url,
p.username as username
p.username as username,
p.full_name as full_name
FROM
comments c1
INNER JOIN
profiles p ON p.id = c1.user_id
WHERE
c1.replied_to_comment_id = ?
GROUP BY
c1.id, p.avatar_url, p.username
c1.id, p.avatar_url, p.username, p.full_name
ORDER BY created_at ASC
''',
parameters: [commentId],
Expand Down Expand Up @@ -1662,7 +1664,7 @@ SELECT * FROM stories WHERE id = ?
}) async {
final result = await _powerSyncRepository.db().getAll(
'''
SELECT up.id, up.username, up.avatar_url
SELECT up.id, up.username, up.full_name, up.avatar_url
FROM profiles up
INNER JOIN likes l ON up.id = l.user_id
INNER JOIN posts p ON l.post_id = p.id
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker_plus/lib/src/entities/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AppTheme {
final Color shimmerBaseColor;
final Color shimmerHighlightColor;

AppTheme({
const AppTheme({
this.primaryColor = Colors.white,
this.focusColor = Colors.black,
this.shimmerBaseColor = const Color.fromARGB(255, 185, 185, 185),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import 'package:flutter/material.dart';

/// [GalleryDisplaySettings] When you make ImageSource from the camera these settings will be disabled because they belong to the gallery.
class GalleryDisplaySettings {
AppTheme? appTheme;
TabsTexts? tabsTexts;
SliverGridDelegateWithFixedCrossAxisCount gridDelegate;
bool showImagePreview;
int maximumSelection;
final AppTheme? appTheme;
final TabsTexts? tabsTexts;
final SliverGridDelegateWithFixedCrossAxisCount gridDelegate;
final bool showImagePreview;
final int maximumSelection;
final AsyncValueSetter<SelectedImagesDetails>? callbackFunction;
final bool cropImage;
final bool pickAvatar;

/// If [cropImage] true [showImagePreview] will be true
/// Right now this package not support crop video
bool cropImage;

GalleryDisplaySettings({
const GalleryDisplaySettings({
this.appTheme,
this.tabsTexts,
this.callbackFunction,
Expand All @@ -24,5 +22,6 @@ class GalleryDisplaySettings {
this.showImagePreview = false,
this.cropImage = false,
this.maximumSelection = 10,
this.pickAvatar = false,
});
}
8 changes: 4 additions & 4 deletions packages/image_picker_plus/lib/src/entities/tabs_texts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ class TabsTexts {
final String photoText;
final String galleryText;
final String deletingText;

/// [limitingText] if the maximumSelection = 10 it will be "The limit is 10 photos or videos."
String? limitingText;
final String? limitingText;
final String holdButtonText;
final String clearImagesText;
final String notFoundingCameraText;
final String noImagesFounded;
final String acceptAllPermissions;
final String noCameraFoundText;
final String newPostText;
final String newAvatarImageText;

TabsTexts({
const TabsTexts({
this.videoText = "VIDEO",
this.photoText = "PHOTO",
this.clearImagesText = "Clear selected images",
Expand All @@ -27,5 +26,6 @@ class TabsTexts {
this.acceptAllPermissions = "Failed! Accept all access permissions.",
this.noCameraFoundText = 'No camera found!',
this.newPostText = 'New post',
this.newAvatarImageText = 'New avatar image',
});
}
9 changes: 5 additions & 4 deletions packages/image_picker_plus/lib/src/gallery_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ class CustomImagePickerState extends State<CustomImagePicker>

_initializeVariables() {
imagePickerDisplay =
widget.galleryDisplaySettings ?? GalleryDisplaySettings();
appTheme = imagePickerDisplay.appTheme ?? AppTheme();
tabsNames = imagePickerDisplay.tabsTexts ?? TabsTexts();
widget.galleryDisplaySettings ?? const GalleryDisplaySettings();
appTheme = imagePickerDisplay.appTheme ?? const AppTheme();
tabsNames = imagePickerDisplay.tabsTexts ?? const TabsTexts();
callbackFunction = imagePickerDisplay.callbackFunction;
cropImage = imagePickerDisplay.cropImage;
maximumSelection = imagePickerDisplay.maximumSelection;
Expand All @@ -92,7 +92,7 @@ class CustomImagePickerState extends State<CustomImagePicker>
showInternalVideos = widget.pickerSource != PickerSource.image;

noGallery = widget.source != ImageSource.camera;
bool notGallery = widget.source != ImageSource.gallery;
final notGallery = widget.source != ImageSource.gallery;

enableCamera = showInternalImages && notGallery;
enableVideo = showInternalVideos && notGallery;
Expand Down Expand Up @@ -308,6 +308,7 @@ class CustomImagePickerState extends State<CustomImagePicker>
maximumSelection: maximumSelection,
filterOption: widget.filterOption,
onBackButtonTap: widget.onBackButtonTap,
pickAvatar: imagePickerDisplay.pickAvatar,
);
}

Expand Down
10 changes: 8 additions & 2 deletions packages/image_picker_plus/lib/src/images_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ImagesViewPage extends StatefulWidget {
final bool showInternalImages;
final int maximumSelection;
final AsyncValueSetter<SelectedImagesDetails>? callbackFunction;
final bool pickAvatar;

/// To avoid lag when you interacting with image when it expanded
final AppTheme appTheme;
Expand Down Expand Up @@ -51,6 +52,7 @@ class ImagesViewPage extends StatefulWidget {
required this.filterOption,
this.callbackFunction,
this.onBackButtonTap,
this.pickAvatar = false,
}) : super(key: key);

@override
Expand Down Expand Up @@ -371,7 +373,9 @@ class _ImagesViewPageState extends State<ImagesViewPage>
elevation: 0,
leading: exitButton(),
centerTitle: false,
title: Text(widget.tabsTexts.newPostText),
title: Text(widget.pickAvatar
? widget.tabsTexts.newAvatarImageText
: widget.tabsTexts.newPostText),
);
}

Expand All @@ -389,7 +393,9 @@ class _ImagesViewPageState extends State<ImagesViewPage>
exitButton(),
const SizedBox(width: 24),
Text(
widget.tabsTexts.newPostText,
widget.pickAvatar
? widget.tabsTexts.newAvatarImageText
: widget.tabsTexts.newPostText,
style: Theme.of(context).textTheme.titleLarge,
)
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AvatarImagePicker extends StatelessWidget {
Future<void> _pickImage(BuildContext context) async {
final file = await PickImage().pickImage(
context,
pickAvatar: true,
source: ImageSource.both,
);
if (file == null) return;
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/lib/src/config/image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class PickImage {
bool cropImage = true,
bool multiImages = false,
bool showPreview = true,
bool pickAvatar = false,
}) =>
context.pickImage(
source: source,
Expand All @@ -100,6 +101,7 @@ class PickImage {
maximumSelection: maxSelection,
showImagePreview: showPreview,
tabsTexts: _tabsTexts,
pickAvatar: pickAvatar,
appTheme: _appTheme(context),
gridDelegate: _sliverGridDelegate(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ extension ListWidgetSpacer on List<Widget> {
double? height,
double? width,
}) {
assert(
height != null && width != null,
'Both height and width can not be specified',
);
return insertBetween(
height != null
? Gap.v(height)
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/lib/src/models/comment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class Comment extends Equatable {
author: PostAuthor(
id: row['user_id'] as String,
avatarUrl: row['avatar_url'] as String? ?? '',
username: row['username'] as String,
username:
row['username'] as String? ?? row['full_name'] as String? ?? '',
),
content: row['content'] as String,
repliedToCommentId: row['replied_to_comment_id'] as String?,
Expand Down

0 comments on commit 9a599d6

Please sign in to comment.