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

Fancy Posts #39

Draft
wants to merge 41 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a13c7fc
chore: extract out post widget
lishaduck Oct 17, 2024
f50f851
wip
lishaduck Oct 18, 2024
adec1de
refactor: clean
lishaduck Oct 18, 2024
8cb58cd
wip
MattsAttack Oct 18, 2024
d3200b9
wip still
MattsAttack Oct 18, 2024
3763453
local and world feed navigation bar
MattsAttack Oct 20, 2024
aa5c11b
wip. updated time value in posts (need to fix difference)
MattsAttack Oct 20, 2024
8c8dfda
rewrote to make difference return a positive value
MattsAttack Oct 20, 2024
49edc17
Added query to sort posts by newest first
MattsAttack Oct 20, 2024
658a023
fixed createPost creating posts in local instead of UTC
MattsAttack Oct 20, 2024
bbae75a
Fixed issues with posts date time.
MattsAttack Oct 20, 2024
3e70fb6
less redundant queries
MattsAttack Oct 20, 2024
85aa1d0
added authorName attribute to Appwrite that gets passed when creating…
MattsAttack Oct 20, 2024
0162fbe
user name attribute added to posts
MattsAttack Oct 20, 2024
b0b2fc4
Avatars!
MattsAttack Oct 21, 2024
af66913
responsive design :(
MattsAttack Oct 21, 2024
5fefa70
change to town talk
MattsAttack Oct 21, 2024
4b21269
wip
MattsAttack Oct 21, 2024
dd6681d
awesome ui changes
MattsAttack Oct 21, 2024
05a45d2
fixed map
MattsAttack Oct 22, 2024
0ee2597
chore(deps): update podfile
lishaduck Oct 23, 2024
f964266
feat: about page
lishaduck Oct 23, 2024
7c44d64
fix: routing coloring
lishaduck Oct 23, 2024
279dfb9
feat: rebrand
lishaduck Oct 23, 2024
b542f7a
Attempted to debug windows build
MattsAttack Nov 20, 2024
5d1fa80
Update melos.yaml
MattsAttack Nov 20, 2024
b3a9c41
Update packages/app/linux/CMakeLists.txt
MattsAttack Nov 20, 2024
078f905
Update packages/app/windows/CMakeLists.txt
MattsAttack Nov 20, 2024
5c74c51
revert CMake executable
MattsAttack Nov 21, 2024
dfbe43e
Changed avatar implementation.
MattsAttack Nov 21, 2024
a7ec715
fix avatar not being saved in local memory
MattsAttack Nov 21, 2024
de4d465
wip
MattsAttack Nov 21, 2024
f8b419a
Revert "wip"
MattsAttack Nov 22, 2024
872cdfd
fix: post scaling
MattsAttack Nov 22, 2024
75671e4
Test Fixes :)
MattsAttack Nov 22, 2024
df7062b
WIP: Like button
MattsAttack Nov 25, 2024
1207487
implement likes string list
MattsAttack Nov 25, 2024
f36979d
WIP: Likes. Need to fix getting post id in PostEntity
MattsAttack Nov 26, 2024
780a463
fix: getting ids in post entity
MattsAttack Nov 26, 2024
dce045b
comments :)
MattsAttack Nov 27, 2024
7152729
WIP: post likes( forgot to commit last week)
MattsAttack Dec 2, 2024
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
1 change: 1 addition & 0 deletions packages/app/lib/src/app/wrapper_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@

@override
Widget build(BuildContext context, WidgetRef ref) {
final formKey = useGlobalKey<FormState>();

Check warning on line 124 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L124

Added line #L124 was not covered by tests
final title = useState('');
final description = useState('');
final id = ref.watch(idProvider);
final username = ref.watch(usernameProvider);

Check warning on line 128 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L127-L128

Added lines #L127 - L128 were not covered by tests

final handleSubmit = useCallback(
() async {
Expand Down Expand Up @@ -157,6 +157,7 @@
description.value,
lat,
lng,
0,
null,
);

Expand All @@ -172,43 +173,43 @@
);

return Dialog(
insetPadding: EdgeInsets.symmetric(
horizontal: MediaQuery.sizeOf(context).width / 8,
vertical: MediaQuery.sizeOf(context).height / 8,

Check warning on line 178 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L176-L178

Added lines #L176 - L178 were not covered by tests
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(

Check warning on line 181 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L180-L181

Added lines #L180 - L181 were not covered by tests
padding: const EdgeInsets.all(40),
child: Scaffold(
appBar: AppBar(

Check warning on line 184 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L183-L184

Added lines #L183 - L184 were not covered by tests
title: const Text('Create a New Post'),
),
body: Form(

Check warning on line 187 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L187

Added line #L187 was not covered by tests
key: formKey,
child: Padding(

Check warning on line 189 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L189

Added line #L189 was not covered by tests
padding: const EdgeInsets.all(16),
child: Column(
children: [
TextFormField(
initialValue: title.value,
onSaved: (value) {

Check warning on line 195 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L191-L195

Added lines #L191 - L195 were not covered by tests
if (value == null) return;

title.value = value;

Check warning on line 198 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L198

Added line #L198 was not covered by tests
},
decoration: const InputDecoration(label: Text('Title')),
),
TextFormField(
initialValue: description.value,
onSaved: (value) {

Check warning on line 204 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L202-L204

Added lines #L202 - L204 were not covered by tests
if (value == null) return;

description.value = value;

Check warning on line 207 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L207

Added line #L207 was not covered by tests
},
decoration:
const InputDecoration(label: Text('Description')),
),
ElevatedButton(

Check warning on line 212 in packages/app/lib/src/app/wrapper_page.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/app/wrapper_page.dart#L212

Added line #L212 was not covered by tests
onPressed: handleSubmit,
child: const Text('Create Post'),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
String? description,
double lat,
double lng,
int numberOfLikes,
String? image,
);
}
Expand Down Expand Up @@ -67,13 +68,13 @@
databaseId: databaseId,
collectionId: collectionId,
queries: [
Query.orderDesc('timestamp'),

Check warning on line 71 in packages/app/lib/src/features/home/data/post_repository.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/data/post_repository.dart#L71

Added line #L71 was not covered by tests
...switch (feed) {
LocalFeed(:final lat, :final lng) => [
Query.between('lat', lat - 2, lat + 2),
Query.between('lng', lng - 2, lng + 2),
],
WorldFeed() => [],

Check warning on line 77 in packages/app/lib/src/features/home/data/post_repository.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/data/post_repository.dart#L77

Added line #L77 was not covered by tests
},
if (cursor != null) Query.cursorAfter(cursor),
Query.limit(pageSize),
Expand All @@ -94,6 +95,7 @@
String? description,
double lat,
double lng,
int numberOfLikes,
String? image,
) async {
await database.createDocument(
Expand All @@ -105,11 +107,12 @@
'headline': headline,
'description': description,
'author': author,
'authorName': authorName,

Check warning on line 110 in packages/app/lib/src/features/home/data/post_repository.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/data/post_repository.dart#L110

Added line #L110 was not covered by tests
'lat': lat,
'lng': lng,
'numberOfLikes': numberOfLikes,
'timestamp':
DateFormat('yyyy-MM-ddTHH:mm:ss').format(DateTime.timestamp()),

Check warning on line 115 in packages/app/lib/src/features/home/data/post_repository.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/data/post_repository.dart#L115

Added line #L115 was not covered by tests
// TODO(MattAttack): add images
},
);
Expand Down
3 changes: 3 additions & 0 deletions packages/app/lib/src/features/home/domain/post_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ sealed class PostEntity with _$PostEntity {
///
required DateTime timestamp,

///
required int numberOfLikes,

/// An optional media to display alongside the post.
String? image,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Feed extends ConsumerWidget {
authorName: '',
lat: 0,
lng: 0,
numberOfLikes: 0,
timestamp: DateTime.timestamp(),
),
),
Expand Down
39 changes: 39 additions & 0 deletions packages/app/lib/src/features/home/presentation/home/post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import '../../application/avatar_service.dart';
Expand Down Expand Up @@ -32,6 +33,7 @@
_PosterInfo(post: post),
const Divider(color: Colors.white), //TODObase on theme
_PostBody(post: post),
_PostInteractables(post: post),
],
),
),
Expand Down Expand Up @@ -67,48 +69,48 @@
final avatar = _PostAvatar(post: post);
if (timeSincePost.inDays > 364) {
//TODOwrite more efficient code with variables
timeValue = (timeSincePost.inDays / 364).round();

Check warning on line 72 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L72

Added line #L72 was not covered by tests
switch (timeValue) {
case 1:
timePostValue = '$timeValue year ago';

Check warning on line 75 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L74-L75

Added lines #L74 - L75 were not covered by tests
default:
timePostValue = '$timeValue years ago';

Check warning on line 77 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L77

Added line #L77 was not covered by tests
}
} else if (timeSincePost.inDays >= 1) {
timeValue = timeSincePost.inDays;

Check warning on line 80 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L80

Added line #L80 was not covered by tests
switch (timeValue) {
case 1:
timePostValue = '$timeValue day ago';

Check warning on line 83 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L82-L83

Added lines #L82 - L83 were not covered by tests
default:
timePostValue = '$timeValue days ago';

Check warning on line 85 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L85

Added line #L85 was not covered by tests
}
} else if (timeSincePost.inHours >= 1) {
timeValue = timeSincePost.inHours;

Check warning on line 88 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L88

Added line #L88 was not covered by tests
switch (timeValue) {
case 1:
timePostValue = '$timeValue hour ago';

Check warning on line 91 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L90-L91

Added lines #L90 - L91 were not covered by tests
default:
timePostValue = '$timeValue hours ago';

Check warning on line 93 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L93

Added line #L93 was not covered by tests
}
} else if (timeSincePost.inMinutes >= 1) {
timeValue = timeSincePost.inMinutes;

Check warning on line 96 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L96

Added line #L96 was not covered by tests
switch (timeValue) {
case 1:
timePostValue = '$timeValue minute ago';

Check warning on line 99 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L98-L99

Added lines #L98 - L99 were not covered by tests
default:
timePostValue = '$timeValue minutes ago';

Check warning on line 101 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L101

Added line #L101 was not covered by tests
}
} else {
timeValue = timeSincePost.inSeconds;
if (timeValue < 1) {
// In case post was made miliseconds ago

Check warning on line 106 in packages/app/lib/src/features/home/presentation/home/post.dart

View workflow job for this annotation

GitHub Actions / Check Spelling

Unknown word (miliseconds)
timeValue = 1;
}
switch (timeValue) {
case 1:
timePostValue = '$timeValue second ago';
default:
timePostValue = '$timeValue seconds ago';

Check warning on line 113 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L113

Added line #L113 was not covered by tests
}
}
return Row(
Expand Down Expand Up @@ -146,7 +148,7 @@

return switch (avatar) {
AsyncData(:final value) => CircleAvatar(
backgroundImage: MemoryImage(value),

Check warning on line 151 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L151

Added line #L151 was not covered by tests
),
AsyncError() => const Text('Error loading avatar'),
_ => const CircularProgressIndicator()
Expand Down Expand Up @@ -198,3 +200,40 @@
}
// coverage:ignore-end
}

class _PostInteractables extends HookWidget {
const _PostInteractables({
required this.post,
// Temporary ignore, see <dart-lang/sdk#49025>.
// ignore: unused_element
super.key,
});

final PostEntity post;

@override
Widget build(BuildContext context) {
final thumbsIcon = useState(const Icon(Icons.thumb_up_outlined));
return Row(
children: [
Text(post.numberOfLikes.toString()),
IconButton(
onPressed: () {
if (thumbsIcon.value.icon == Icons.thumb_up_outlined) {
thumbsIcon.value = const Icon(Icons.thumb_up_sharp);

Check warning on line 223 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L221-L223

Added lines #L221 - L223 were not covered by tests
} else {
thumbsIcon.value = const Icon(Icons.thumb_up_outlined);

Check warning on line 225 in packages/app/lib/src/features/home/presentation/home/post.dart

View check run for this annotation

Codecov / codecov/patch

packages/app/lib/src/features/home/presentation/home/post.dart#L225

Added line #L225 was not covered by tests
}
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant as an animation? 🤣

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe eventually. right now it just updates the icon of the thumb when you click it

icon: thumbsIcon.value,
),
],
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<PostEntity>('post', post));
}
}
Loading