Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Messages improvements #186

Merged
merged 6 commits into from
Jan 1, 2025
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
5 changes: 5 additions & 0 deletions app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"on_internet_error_title": "No Internet!",
"on_internet_error_sub_title": "No Internet Connection. Please check your network settings and try again.",

"@_ERROR": {
},
"errorNoConnection": "No internet connection detected.",
"errorGeneric": "Something went wrong. Please try again.",

"@_INTRO": {
},
"intro_1_title": "Live location",
Expand Down
2 changes: 1 addition & 1 deletion app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 9bf7626a50066852dd21123c4db8e9fe30622485

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
23 changes: 23 additions & 0 deletions app/lib/domain/extenstions/api_error_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:data/network/error.dart';
import 'package:flutter/cupertino.dart';
import 'package:yourspace_flutter/domain/extenstions/context_extenstions.dart';


extension AppErrorExtensions on Object {
String l10nMessage(BuildContext context) {
switch (runtimeType) {
case const (NoInternetConnectionError):
return context.l10n.errorNoConnection;
case const (GenericError):
return context.l10n.errorGeneric;
case const (String):
return this as String;
case const (StringError):
return (this as StringError).error;
case const (ApiError):
return (this as ApiError).message ?? context.l10n.errorGeneric;
default:
return context.l10n.errorGeneric;
}
}
}
12 changes: 4 additions & 8 deletions app/lib/ui/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,16 @@ class AppRoute {
}

static AppRoute chat({
String? spaceId,
ApiSpace? space,
String? threadId,
String? spaceName,
List<ApiThreadMessage>? threadMessage,
List<ThreadInfo>? threadInfoList,
List<ApiThread>? threads,
}) {
return AppRoute(
pathMessage,
builder: (_) => ChatScreen(
spaceId: spaceId,
spaceName: spaceName ?? '',
space: space,
threadId: threadId,
threadMessages: threadMessage,
threadInfoList: threadInfoList,
threadInfoList: threads,
),
);
}
Expand Down
5 changes: 4 additions & 1 deletion app/lib/ui/components/error_snakebar.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'dart:io';

import 'package:data/network/error.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:yourspace_flutter/domain/extenstions/api_error_extension.dart';

void showErrorSnackBar(BuildContext context, Object error) {
HapticFeedback.mediumImpact();
showSnackBar(context, error.toString(), length: SnackBarLength.long);
final message = ApiError.fromError(error).l10nMessage(context);
showSnackBar(context, message, length: SnackBarLength.long);
}

void showSnackBar(
Expand Down
28 changes: 28 additions & 0 deletions app/lib/ui/components/on_visible_callback.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/cupertino.dart';

class OnVisibleCallback extends StatefulWidget {
final void Function() onVisible;
final Widget child;

const OnVisibleCallback({
super.key,
required this.onVisible,
required this.child,
});

@override
State<OnVisibleCallback> createState() => _OnCreateState();
}

class _OnCreateState extends State<OnVisibleCallback> {
@override
void initState() {
widget.onVisible();
super.initState();
}

@override
Widget build(BuildContext context) {
return widget.child;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ class _$LocateOnMapStateImpl implements _LocateOnMapState {
.equals(other.addingPlace, addingPlace) &&
const DeepCollectionEquality()
.equals(other.gettingAddress, gettingAddress) &&
const DeepCollectionEquality()
.equals(other.currentLatLng, currentLatLng) &&
const DeepCollectionEquality()
.equals(other.cameraLatLng, cameraLatLng) &&
(identical(other.currentLatLng, currentLatLng) ||
other.currentLatLng == currentLatLng) &&
(identical(other.cameraLatLng, cameraLatLng) ||
other.cameraLatLng == cameraLatLng) &&
(identical(other.address, address) || other.address == address) &&
const DeepCollectionEquality()
.equals(other.centerPosition, centerPosition) &&
(identical(other.centerPosition, centerPosition) ||
other.centerPosition == centerPosition) &&
(identical(other.popToPlaceList, popToPlaceList) ||
other.popToPlaceList == popToPlaceList) &&
const DeepCollectionEquality().equals(other.error, error));
Expand All @@ -250,10 +250,10 @@ class _$LocateOnMapStateImpl implements _LocateOnMapState {
const DeepCollectionEquality().hash(loading),
const DeepCollectionEquality().hash(addingPlace),
const DeepCollectionEquality().hash(gettingAddress),
const DeepCollectionEquality().hash(currentLatLng),
const DeepCollectionEquality().hash(cameraLatLng),
currentLatLng,
cameraLatLng,
address,
const DeepCollectionEquality().hash(centerPosition),
centerPosition,
popToPlaceList,
const DeepCollectionEquality().hash(error));

Expand Down
12 changes: 6 additions & 6 deletions app/lib/ui/flow/home/map/map_view_model.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,10 @@ class _$MapViewStateImpl implements _MapViewState {
.equals(other._userInfos, _userInfos) &&
(identical(other.selectedUser, selectedUser) ||
other.selectedUser == selectedUser) &&
const DeepCollectionEquality()
.equals(other.currentUserLocation, currentUserLocation) &&
const DeepCollectionEquality()
.equals(other.defaultPosition, defaultPosition) &&
(identical(other.currentUserLocation, currentUserLocation) ||
other.currentUserLocation == currentUserLocation) &&
(identical(other.defaultPosition, defaultPosition) ||
other.defaultPosition == defaultPosition) &&
(identical(other.spaceInvitationCode, spaceInvitationCode) ||
other.spaceInvitationCode == spaceInvitationCode) &&
(identical(other.mapType, mapType) || other.mapType == mapType) &&
Expand All @@ -424,8 +424,8 @@ class _$MapViewStateImpl implements _MapViewState {
const DeepCollectionEquality().hash(_places),
const DeepCollectionEquality().hash(_userInfos),
selectedUser,
const DeepCollectionEquality().hash(currentUserLocation),
const DeepCollectionEquality().hash(defaultPosition),
currentUserLocation,
defaultPosition,
spaceInvitationCode,
mapType,
const DeepCollectionEquality().hash(error),
Expand Down
Loading
Loading