Skip to content

Commit

Permalink
feat: ux and ui improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusamelio committed Jan 28, 2024
1 parent c4485e8 commit 335a2d1
Show file tree
Hide file tree
Showing 73 changed files with 2,523 additions and 970 deletions.
1 change: 1 addition & 0 deletions assets/animations/praise.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.0.0
## Added
- New praise flow
- Multi praised praises
- Praise reactions
- Praise animations
- Auto filling community according to last praise sent

# 1.2.6
## Added
- Slack auth
Expand Down
4 changes: 3 additions & 1 deletion lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ class App extends StatelessWidget {
);
};

return child!;
return Sizer(builder: (context, orientation, deviceType) {
return child!;
});
},
),
);
Expand Down
3 changes: 3 additions & 0 deletions lib/colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'dart:ui';

const purple = Color(0XFF8452DA);
1 change: 1 addition & 0 deletions lib/contexts/community/community.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export "./application/application.dart";
export "./dependencies.dart";
export "./presentation/presentation.dart";
export "./business/business.dart";
export "./infra/infra.dart";
12 changes: 12 additions & 0 deletions lib/contexts/community/dependencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,16 @@ Future<void> communityDependencies() async {
),
),
);

inject<GetPraisesSentByUserQuery>(
GetPraisesSentByUserQuery(
databaseDatasource: injected(),
),
);

inject<PraisesSentController>(
DefaultPraisesSentController(
getPraisesSentByUserQuery: injected(),
),
);
}
1 change: 1 addition & 0 deletions lib/contexts/community/infra/infra.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export "./query.dart";
97 changes: 97 additions & 0 deletions lib/contexts/community/infra/query.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import '../../../core/core.dart';
import '../../../core/external_dependencies.dart';
import '../../../shared/dtos/dtos.dart';

class GetPraisesSentByUserQueryInput extends QueryInput {
const GetPraisesSentByUserQueryInput({
required this.userId,
required this.praised,
required this.communityId,
});

final String userId;
final UserDto praised;
final String communityId;
}

class GetPraisesSentByUserQueryOutput extends QueryOutput<List<PraiseDto>> {
GetPraisesSentByUserQueryOutput(super.value);
}

class GetPraisesSentByUserQuery
extends DataQuery<GetPraisesSentByUserQueryInput> {
GetPraisesSentByUserQuery({
required DatabaseDatasource databaseDatasource,
}) : _datasource = databaseDatasource;

final DatabaseDatasource _datasource;
@override
Future<Either<QueryError, GetPraisesSentByUserQueryOutput>> call(
GetPraisesSentByUserQueryInput input,
) async {
final result = await _datasource.get(
GetQuery(
sourceName: praisesCollection,
operator: FilterOperator.equalsTo,
value: input.praised.id,
fieldName: "praised_id",
orderBy: const OrderFilter(field: "created_at"),
select:
"*, $communitiesCollection(title), $profilesCollection!praise_praiser_id_fkey(name, tag, id, email), $reactionsCollection(id, reaction, user_id)",
filters: [
AndFilter(
fieldName: "praiser_id",
operator: FilterOperator.equalsTo,
value: input.userId,
),
AndFilter(
fieldName: "community_id",
operator: FilterOperator.equalsTo,
value: input.communityId,
),
],
),
);

if (result.failure) {
return Left(QueryError(result.errorMessage!));
}

return Right(
GetPraisesSentByUserQueryOutput(
result.multiData!
.map(
(e) => PraiseDto(
id: e["id"],
message: e["message"],
topic: e["topic"],
communityName: e[communitiesCollection]["title"],
communityId: input.communityId,
private: e["private"],
praiser: UserDto(
tag: e[profilesCollection]["tag"],
name: e[profilesCollection]["name"],
email: e[profilesCollection]["email"],
id: e[profilesCollection]["id"],
),
praised: input.praised,
reactions: e[reactionsCollection] != null
? (e[reactionsCollection] as List)
.cast<Map<String, dynamic>>()
.map(
(reaction) => PraiseReactionDto(
userId: reaction["user_id"],
id: reaction["id"],
praiseId: e["id"],
reaction: reaction["reaction"],
),
)
.toList()
: [],
),
)
.toList(),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,20 @@ class DefaultCommunityDetailsController
);
state.set(membersOrError.fold(
(left) => ErrorState(left),
(right) => SuccessState(
right.value,
),
(right) {
final List<FindCommunityMemberOutput> value = right.value;
final Set<String> uniqueMemberTags = value.map((e) => e.tag).toSet();

return SuccessState(
uniqueMemberTags
.map(
(e) => value.lastWhere(
(element) => element.tag == e,
),
)
.toList(),
);
},
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export "./get_communities.dart";
export "./new_community.dart";
export './community_details.dart';
export "./invite.dart";
export "./praises_sent.dart";
82 changes: 82 additions & 0 deletions lib/contexts/community/presentation/controllers/praises_sent.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import 'dart:async';

import '../../../../core/core.dart';
import '../../../../core/external_dependencies.dart';
import '../../../../shared/dtos/dtos.dart';
import '../../infra/infra.dart';

abstract interface class PraisesSentController {
AtomNotifier<DefaultState<Exception, List<PraiseDto>>> get state;

Future<void> get({
required String communityId,
required String userId,
required String praisedId,
});

void addReaction(PraiseReactionDto reaction);
void removeReaction(PraiseReactionDto reaction);
}

class DefaultPraisesSentController implements PraisesSentController {
DefaultPraisesSentController({
required GetPraisesSentByUserQuery getPraisesSentByUserQuery,
}) : _query = getPraisesSentByUserQuery;
final GetPraisesSentByUserQuery _query;

@override
final AtomNotifier<DefaultState<Exception, List<PraiseDto>>> state =
AtomNotifier(InitialState());

@override
Future<void> get({
required String communityId,
required String userId,
required String praisedId,
}) async {
state.set(LoadingState());
final praisesOrError = await _query.call(
GetPraisesSentByUserQueryInput(
userId: userId,
praised: UserDto(
tag: "",
name: "",
email: "",
id: praisedId,
),
communityId: communityId,
),
);
state.set(
praisesOrError.fold(
(left) => ErrorState(left),
(right) => SuccessState(right.value),
),
);
}

@override
void addReaction(PraiseReactionDto input) {
final data = (state.value as SuccessState<Exception, List<PraiseDto>>).data;

final index = data.indexWhere((element) => element.id == input.praiseId);

data[index] = data[index].copyWith(
reactions: [
...data[index].reactions,
input,
],
);
state.set(SuccessState(data));
}

@override
void removeReaction(PraiseReactionDto input) {
final data = (state.value as SuccessState<Exception, List<PraiseDto>>).data;
final index = data.indexWhere((element) => element.id == input.praiseId);
data[index].reactions.removeWhere(
(element) => element.id == input.id,
);
state.set(SuccessState(data));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:blurple/widgets/buttons/buttons.dart';
import 'package:boxy/flex.dart';
import 'package:flutter/material.dart';

import '../../../../core/core.dart';
import '../../../../core/external_dependencies.dart';
import '../../../../shared/shared.dart';
import '../presentation.dart';

class MemberOptionsSheet extends StatelessWidget {
const MemberOptionsSheet({
super.key,
required this.canRemove,
required this.member,
required this.community,
});

final bool canRemove;
final FindCommunityMemberOutput member;
final CommunityOutput community;

@override
Widget build(BuildContext context) {
return BottomSheetMolecule(
child: SizedBox(
width: 80.w,
child: BoxyColumn(
mainAxisSize: MainAxisSize.min,
children: [
if (canRemove)
BaseButton.icon(
label: "Remover",
backgroundColor: Colors.black45,
foregroundColor: Colors.white,
onPressed: () {
Navigator.of(context).pop();
showCustomModalBottomSheet(
context: context,
child: RemoveMemberSheet(
member: member,
community: community,
),
);
},
icon: const Icon(HeroiconsSolid.trash),
),
SizedBox.square(
dimension: context.theme.spacingScheme.verticalSpacing,
),
BaseButton.icon(
label: "Ver praises enviados",
backgroundColor: Colors.black45,
foregroundColor: Colors.white,
onPressed: () {
Navigator.of(context).pushNamed(
PraisesSentScreen.routeName,
arguments: PraisesSentArgs(
community: community,
member: member,
),
);
},
icon: const Icon(HeroiconsSolid.magnifyingGlass),
),
SizedBox.square(
dimension: context.theme.spacingScheme.verticalSpacing,
),
],
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export 'save_community_sheet.dart';
export "./invite_member_sheet.dart";
export "./member_search_bar.dart";
export "./remove_member_sheet.dart";
export "./member_options_sheet.dart";
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class _RemoveMemberSheetState extends State<RemoveMemberSheet> {
child: PolymorphicAtomObserver<DefaultState<Exception, void>>(
atom: controller.state,
types: [
TypedAtomHandler(
type: LoadingState<Exception, void>,
TypedAtomHandler<LoadingState<Exception, void>>(
builder: (context, state) => const LoaderMolecule(),
)
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '../../../../shared/presentation/molecules/molecules.dart';
import '../controllers/controllers.dart';

class SaveCommunitySheet extends StatefulWidget {
const SaveCommunitySheet({Key? key, this.community}) : super(key: key);
const SaveCommunitySheet({super.key, this.community});
final CommunityOutput? community;
@override
State<SaveCommunitySheet> createState() => _SaveCommunitySheetState();
Expand Down Expand Up @@ -113,9 +113,10 @@ class _SaveCommunitySheetState extends State<SaveCommunitySheet> {

return const SizedBox.shrink();
},
child: const Icon(
child: Icon(
HeroiconsSolid.photo,
size: 60,
color: Colors.white.withOpacity(.7),
),
),
),
Expand Down
Loading

0 comments on commit 335a2d1

Please sign in to comment.