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

User profile screen v2 #76

Merged
merged 19 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
655fee5
feat(profile): simplifying the UI for the profile page by taking away…
TheTexanCodeur Apr 9, 2024
80633de
feat(profile): added tab navigation between posts and comments
TheTexanCodeur Apr 9, 2024
b6ad552
feat(profile): added tests for this new version of the profile page
TheTexanCodeur Apr 9, 2024
e312ce1
fix(profile): cleaned code that is not used anymore
TheTexanCodeur Apr 9, 2024
295a00a
feat(profile): UI is even more refined with for example the addition …
TheTexanCodeur Apr 10, 2024
6c00d7b
feat(profile): Added mock material in the info cards.
TheTexanCodeur Apr 10, 2024
f1b8226
feat(profile): added more precise tests that check if all types if i…
TheTexanCodeur Apr 10, 2024
f7d1ced
fix(profile): remplaced old buggy card display with "ListTile" widgets
TheTexanCodeur Apr 10, 2024
9b85408
Merge branch 'main' into user-profile-v2
TheTexanCodeur Apr 10, 2024
6fe3478
fix(profile): removed wrong padding
TheTexanCodeur Apr 10, 2024
2843713
Update lib/views/pages/profile/posts_info/info_card_comment.dart
TheTexanCodeur Apr 10, 2024
783315c
Update lib/views/pages/profile/posts_info/info_card_post.dart
TheTexanCodeur Apr 10, 2024
a25cef5
Update lib/views/pages/profile/posts_info/info_row.dart
TheTexanCodeur Apr 10, 2024
20056f9
Apply suggestions from code review
TheTexanCodeur Apr 10, 2024
5a429e6
fix(profile): added missing import in user profile test file
TheTexanCodeur Apr 10, 2024
a5b2724
feat(profile): Pass card texts directly as parameters
TheTexanCodeur Apr 11, 2024
5c2450f
Merge branch 'main' into user-profile-v2
TheTexanCodeur Apr 11, 2024
de69418
fix(profile): The email check is now done before we pass it to the wi…
TheTexanCodeur Apr 11, 2024
19c9381
fix(profile): added missing trailing comma
TheTexanCodeur Apr 11, 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
14 changes: 7 additions & 7 deletions lib/views/pages/home/top_bar/home_top_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class HomeTopBar extends HookConsumerWidget {
style: Theme.of(context).textTheme.headlineMedium,
);

Widget userAvatar = InkWell(
key: profilePictureKey,
onTap: () {
Navigator.pushNamed(context, Routes.profile.name);
},
child: const CircleAvatar(
child: Text("PR"),
Widget userAvatar = CircleAvatar(
child: InkWell(
key: profilePictureKey,
onTap: () {
Navigator.pushNamed(context, Routes.profile.name);
},
child: const Text("PR"),
),
);

Expand Down
12 changes: 3 additions & 9 deletions lib/views/pages/profile/posts_info/info_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ class InfoCard extends StatelessWidget {

const InfoCard({
super.key,
required this.theme,
});

final ThemeData theme;

@override
Widget build(BuildContext context) {
return Container(
key: cardKey,
width: 92,
height: 92,
width: 54,
height: 80,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2,
),
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
);
Expand Down
50 changes: 12 additions & 38 deletions lib/views/pages/profile/posts_info/info_column.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,27 @@ import "package:flutter/material.dart";
/// This widget defines the style of the columns in the profile page,
/// such as the posts and comments columns
class InfoColumn extends StatelessWidget {
static const infoColumnKey = Key("info column");
const InfoColumn({
super.key,
required this.theme,
required this.itemList,
required this.title,
required this.colKey,
});

final ThemeData theme;
final List<Widget> itemList;
final String title;
final Key colKey;

@override
Widget build(BuildContext context) {
return Container(
key: infoColumnKey,
height: 275,
width: 380,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(10)),
color: theme.colorScheme.secondaryContainer,
),
child: Padding(
padding: const EdgeInsets.only(left: 5, right: 5, top: 1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: theme.textTheme.headlineSmall,
),
const SizedBox(height: 5),
Expanded(
child: ListView.separated(
padding: const EdgeInsets.all(8),
scrollDirection: Axis.vertical,
itemCount: itemList.length,
itemBuilder: (BuildContext context, int index) {
return itemList[index];
},
separatorBuilder: (BuildContext context, int index) =>
const SizedBox(height: 10),
),
),
],
),
),
return ListView.separated(
key: colKey,
padding: const EdgeInsets.all(8),
scrollDirection: Axis.vertical,
itemCount: itemList.length,
itemBuilder: (BuildContext context, int index) {
return itemList[index];
},
separatorBuilder: (BuildContext context, int index) =>
const SizedBox(height: 10),
);
}
}
11 changes: 4 additions & 7 deletions lib/views/pages/profile/posts_info/info_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@ class InfoRow extends StatelessWidget {
static const infoRowKey = Key("info row");
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved
const InfoRow({
super.key,
required this.theme,
required this.itemList,
required this.title,
});

final ThemeData theme;
final List<Widget> itemList;
final String title;

@override
Widget build(BuildContext context) {
return Container(
key: infoRowKey,
height: 150,
height: 100,
width: 380,
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(10)),
color: theme.colorScheme.secondaryContainer,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Padding(
padding: const EdgeInsets.only(left: 5, top: 1),
Expand All @@ -32,7 +29,7 @@ class InfoRow extends StatelessWidget {
children: [
Text(
title,
style: theme.textTheme.headlineSmall,
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 5),
Expanded(
Expand Down
111 changes: 61 additions & 50 deletions lib/views/pages/profile/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,87 @@ import "package:proxima/viewmodels/profile_view_model.dart";
import "package:proxima/views/pages/profile/posts_info/info_card.dart";
import "package:proxima/views/pages/profile/posts_info/info_column.dart";
import "package:proxima/views/pages/profile/posts_info/info_row.dart";
import "package:proxima/views/pages/profile/user_info/centauri_points.dart";
import "package:proxima/views/pages/profile/user_info/user_account.dart";

/// This widget is used to display the profile page
/// It contains the user info, centauri points, badges, posts and comments
class ProfilePage extends HookConsumerWidget {
const ProfilePage({super.key});
static const postTabKey = Key("post tab");
static const commentTabKey = Key("comment tab");
static const tabKey = Key("tab");
static const postColumnKey = Key("post column");
static const commentColumnKey = Key("comment column");
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved

@override
Widget build(BuildContext context, WidgetRef ref) {
final asyncUserData = ref.watch(profileProvider);

final theme = Theme.of(context);

var itemList = <InfoCard>[];

for (var i = 0; i < 5; i++) {
for (var i = 0; i < 10; i++) {
itemList.add(
InfoCard(
theme: theme,
),
const InfoCard(),
);
}
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved

return switch (asyncUserData) {
AsyncData(:final value) => Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
title: UserAccount(theme: theme, userEmail: value.user.email),
actions: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {},
AsyncData(:final value) => DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.pop(context);
},
),
],
),
body: Container(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Center(
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 15),
CentauriPoints(theme: theme),
const SizedBox(height: 15),
InfoRow(
theme: theme,
itemList: itemList,
title: "Your badges:",
),
const SizedBox(height: 15),
InfoColumn(
theme: theme,
itemList: itemList,
title: "Your posts:",
),
const SizedBox(height: 15),
InfoColumn(
theme: theme,
itemList: itemList,
title: "Your comments:",
),
const SizedBox(height: 15),
],
title: UserAccount(userEmail: value.user.email),
actions: [
IconButton(
icon: const Icon(Icons.settings),
onPressed: () {},
),
],
),
body: Container(
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
child: Column(
children: [
const SizedBox(height: 8),
InfoRow(
itemList: itemList,
title: "Your badges:",
),
const TabBar(
key: tabKey,
tabs: [
Tab(
text: "Posts",
key: postTabKey,
),
Tab(
text: "Comments",
key: commentTabKey,
),
],
),
const SizedBox(height: 8),
Expanded(
child: TabBarView(
children: [
InfoColumn(
itemList: itemList,
colKey: postColumnKey,
),
InfoColumn(
itemList: itemList,
colKey: commentColumnKey,
),
],
),
),
],
),
),
),
Expand Down
34 changes: 0 additions & 34 deletions lib/views/pages/profile/user_info/centauri_points.dart

This file was deleted.

11 changes: 6 additions & 5 deletions lib/views/pages/profile/user_info/user_account.dart
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import "package:flutter/material.dart";
/// This widget display the user info in the profile page
class UserAccount extends StatelessWidget {
static const userInfoKey = Key("user Info");
static const centauriPointsKey = Key("centauri points");
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved

const UserAccount({
super.key,
required this.theme,
required this.userEmail,
});

final ThemeData theme;
final String? userEmail;

@override
Expand All @@ -31,12 +30,14 @@ class UserAccount extends StatelessWidget {
//TODO: get the profile info from the viewmodel
Text(
userEmail ?? "averylongemailjusttocheckthatitfades",
TheTexanCodeur marked this conversation as resolved.
Show resolved Hide resolved
style: theme.textTheme.titleSmall,
style: Theme.of(context).textTheme.titleSmall,
overflow: TextOverflow.fade,
),
Text(
"User Profile",
style: theme.textTheme.titleSmall,
//TODO: get the user points from the viewmodel
"User Profile · 1000 Points ",
style: Theme.of(context).textTheme.titleSmall,
key: centauriPointsKey,
),
],
),
Expand Down
Loading