Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

"Update profile page title, refactor login function names, and add user logout functionality" #26

Merged
merged 33 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b07580e
chore: update profile page title and add logout button
xuelink Jun 27, 2024
ef16cbf
chore: Update profile page to remove logger dependency and replace wi…
xuelink Jun 27, 2024
770b8e2
feat: Add logUserOut function for user logout functionality
xuelink Jun 27, 2024
ea6edf9
chore: Refactor login function names for consistency
xuelink Jun 27, 2024
6d54efb
Update login and home page imports to include the necessary files for…
xuelink Jun 27, 2024
f81441d
chore: Update login and home page imports for authentication and user…
xuelink Jun 27, 2024
c7ff369
chore: Update component imports for profile cards
xuelink Jun 27, 2024
29215e2
chore: Update API service imports and initialize client components
xuelink Jun 27, 2024
8589395
chore: Update profile page to include logout functionality
xuelink Jun 27, 2024
7b2a432
Update component folder
xuelink Jun 27, 2024
bd9edf6
chrore: Update assets folder
xuelink Jun 27, 2024
ba7fb43
Update component imports for profile cards
xuelink Jun 27, 2024
3caacaf
added new folders
xuelink Jun 27, 2024
fa09edd
chore: Add listUsers function to user service
xuelink Jun 27, 2024
e82c929
fix: deleted images folder
xuelink Jun 27, 2024
a14580d
feat: Add flutter_riverpod dependency, version 2.5.1
xuelink Jun 27, 2024
ad3c250
feat: start with riverpod
xuelink Jun 28, 2024
8e9801c
chore: Update authentication notifier to include debug print statements
xuelink Jun 28, 2024
1672a2c
feat: Update main.dart with authentication provider and login flow
xuelink Jun 28, 2024
7604f88
Update profile page with Riverpod integration and authentication prov…
xuelink Jun 28, 2024
07feae2
refactor: dfault moved to components folder
xuelink Jun 28, 2024
26025fe
feat: Update login screen with Riverpod integration and authenticatio…
xuelink Jun 28, 2024
4ea8bd1
refactor: Remove unused imports and simplify login and logout services
xuelink Jun 28, 2024
c5159cb
feat: Update login screen with optimized Apple login button
xuelink Jun 28, 2024
aa1f44a
refactor: Update listUsers function to return response documents
xuelink Jun 28, 2024
79725aa
feat: Add UserNotifier to fetch and store users from UserService
xuelink Jun 28, 2024
c2e0458
feat: Add userProvider to manage user state
xuelink Jun 28, 2024
0e42613
feat: Update Community page to fetch and display users using userProv…
xuelink Jun 28, 2024
85e6451
feat: Handle error messages in authNotifier and display them in the UI
xuelink Jun 28, 2024
8acf7db
refactor: Update listUsers function to include query for ordering by …
xuelink Jun 28, 2024
ef2f7a1
refactor: Moved auth_notifier.dart and user_notifier.dart to auth_pro…
xuelink Jun 28, 2024
ffdc6ef
refactor: Move user_provider.dart to providers directory
xuelink Jun 28, 2024
9ea5a33
refactor: Remove unused imports and simplify login and logout services
xuelink Jun 28, 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
6 changes: 0 additions & 6 deletions lib/appwrite.dart

This file was deleted.

File renamed without changes.
28 changes: 0 additions & 28 deletions lib/components/headappbar.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/info_svg.dart';
import 'package:langx_flutter/components/country_svg.dart';
import 'package:langx_flutter/components/gender_svg.dart';
import 'package:langx_flutter/components/calendar_svg.dart';
import 'package:langx_flutter/components/clock_svg.dart';
import 'package:langx_flutter/components/at_sign_svg.dart';
import 'package:langx_flutter/components/shield_svg.dart';

// Components Import
import 'package:langx_flutter/assets/svg/info_svg.dart';
import 'package:langx_flutter/assets/svg/country_svg.dart';
import 'package:langx_flutter/assets/svg/gender_svg.dart';
import 'package:langx_flutter/assets/svg/calendar_svg.dart';
import 'package:langx_flutter/assets/svg/clock_svg.dart';
import 'package:langx_flutter/assets/svg/at_sign_svg.dart';
import 'package:langx_flutter/assets/svg/shield_svg.dart';

class ProfileAboutMeCard extends StatelessWidget {
final String country;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/info_svg.dart';

// Components Imports
import 'package:langx_flutter/assets/svg/info_svg.dart';

class ProfileDayStreaksCard extends StatelessWidget {
final String imgUrl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/word_svg.dart';

// Components Imports
import 'package:langx_flutter/assets/svg/word_svg.dart';

class MotherTonguesCard extends StatelessWidget {
final List<String> languages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/people_svg.dart';
import 'package:langx_flutter/components/eye_svg.dart';

// Components Imports
import 'package:langx_flutter/assets/svg/people_svg.dart';
import 'package:langx_flutter/assets/svg/eye_svg.dart';

class OthersCard extends StatelessWidget {
const OthersCard({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/battery_svg.dart';

// Components Imports
import 'package:langx_flutter/assets/svg/battery_svg.dart';

class StudyLanguagesCard extends StatelessWidget {
final List<String> languages;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/trophy_svg.dart';
import 'package:langx_flutter/components/info_svg.dart';

// Components Imports
import 'package:langx_flutter/assets/svg/trophy_svg.dart';
import 'package:langx_flutter/assets/svg/info_svg.dart';

class ProfileTokenCard extends StatelessWidget {
final String imgUrl;
Expand Down
Empty file added lib/extras/.gitkeep
Empty file.
60 changes: 53 additions & 7 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,73 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
//import 'package:langx_flutter/pages/login/login.dart';

// Themes Import
import 'package:langx_flutter/theme.dart';

// Pages Import
import 'package:langx_flutter/pages/login/login.dart';
import 'package:langx_flutter/pages/home/home.dart';

// Providers Import
import 'package:langx_flutter/providers/auth_provider.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: ".env");

runApp(const Main());
runApp(
const ProviderScope(
child: Main(),
),
);
}

class Main extends StatelessWidget {
class Main extends ConsumerWidget {
const Main({super.key});

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final authStatus = ref.watch(authProvider);
final authNotifier = ref.read(authProvider.notifier);

return MaterialApp(
theme: whiteTheme(),
darkTheme: darkTheme(),
// home: const LoginScreen(),
home: const Home(),
// home: const Home(),
home: Scaffold(
body: Builder(
builder: (context) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (authNotifier.errorMessage != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(authNotifier.errorMessage!)),
);
authNotifier
.clearErrorMessage(); // Clear the error message after displaying it
}
});

return authStatus == AuthStatus.loading
? const SplashScreen()
: authStatus == AuthStatus.authenticated
? const Home()
: const LoginScreen();
},
),
),
);
}
}

class SplashScreen extends StatelessWidget {
const SplashScreen({super.key});

@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
}
Empty file added lib/models/.gitkeep
Empty file.
74 changes: 46 additions & 28 deletions lib/pages/home/community.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/usercard.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class Community extends StatefulWidget {
// Components Import
import 'package:langx_flutter/components/community/usercard.dart';
import 'package:langx_flutter/providers/user_provider.dart';

class Community extends ConsumerStatefulWidget {
const Community({super.key});

@override
State<Community> createState() => _CommunityState();
ConsumerState<Community> createState() => _CommunityState();
}

class _CommunityState extends State<Community> {
class _CommunityState extends ConsumerState<Community> {
@override
void initState() {
super.initState();
ref.read(userProvider.notifier).fetchUsers();
}

Widget buildCategoryButton(IconData icon, String label, Color iconColor) {
return GestureDetector(
onTap: () {},
Expand Down Expand Up @@ -49,6 +59,8 @@ class _CommunityState extends State<Community> {
double width = MediaQuery.of(context).size.width;
int crossAxisCount = _calculateCrossAxisCount(width);

final users = ref.watch(userProvider);

return Scaffold(
backgroundColor: const Color.fromARGB(31, 163, 163, 163),
body: CustomScrollView(
Expand Down Expand Up @@ -140,30 +152,36 @@ class _CommunityState extends State<Community> {
),
),
),
SliverPadding(
padding: const EdgeInsets.all(8.0),
sliver: SliverGrid(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return UserCard(
name: 'User ${index + 1}',
age: 18 + index,
studies: 'Studies info',
speaks: 'Speaks info',
imageUrl: 'assets/images/preview.png',
status: 'Active',
);
},
childCount: 12,
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
childAspectRatio: 0.75,
),
),
),
users.isEmpty
? const SliverToBoxAdapter(
child: Center(child: CircularProgressIndicator()),
)
: SliverPadding(
padding: const EdgeInsets.all(8.0),
sliver: SliverGrid(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
final user = users[index].data;
return UserCard(
name: user['name'].toString(),
age: user['age'] ?? 0,
studies: user['studyLanguages'].toString(),
speaks: user['motherLanguages'].toString(),
imageUrl:
user['imageUrl'] ?? 'assets/images/preview.png',
status: user['status'] ?? 'Active',
);
},
childCount: users.length,
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
childAspectRatio: 0.75,
),
),
),
],
),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';

// Pages Import
import 'package:langx_flutter/pages/home/community.dart';
import 'package:langx_flutter/pages/home/profile.dart';

Expand Down
54 changes: 36 additions & 18 deletions lib/pages/home/profile.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,48 @@
import 'package:flutter/material.dart';
import 'package:langx_flutter/components/profile_user_card.dart';
import 'package:langx_flutter/components/profile_token_card.dart';
import 'package:langx_flutter/components/profile_day_streaks_card.dart';
import 'package:langx_flutter/components/profile_about_me_card.dart';
import 'package:langx_flutter/components/profile_study_languages_card.dart';
import 'package:langx_flutter/components/profile_mother_tongues_card.dart';
import 'package:langx_flutter/components/profile_badges_card.dart';
import 'package:langx_flutter/components/profile_others_card.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class Profile extends StatefulWidget {
// Providers Import
import 'package:langx_flutter/providers/auth_provider.dart';

// Components Import
import 'package:langx_flutter/components/profile/user_card.dart';
import 'package:langx_flutter/components/profile/token_card.dart';
import 'package:langx_flutter/components/profile/day_streaks_card.dart';
import 'package:langx_flutter/components/profile/about_me_card.dart';
import 'package:langx_flutter/components/profile/study_languages_card.dart';
import 'package:langx_flutter/components/profile/mother_tongues_card.dart';
import 'package:langx_flutter/components/profile/badges_card.dart';
import 'package:langx_flutter/components/profile/others_card.dart';

class Profile extends ConsumerStatefulWidget {
const Profile({super.key});

@override
State<Profile> createState() => _ProfileState();
ConsumerState<Profile> createState() => _ProfileState();
}

class _ProfileState extends State<Profile> {
class _ProfileState extends ConsumerState<Profile> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Profile",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
)),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text("Profile"),
Row(
children: [
GestureDetector(
onTap: () async {
ref.read(authProvider.notifier).logout(context);
},
child: const Icon(Icons.exit_to_app_outlined, size: 30),
),
const SizedBox(width: 10.0),
],
),
],
),
centerTitle: false,
backgroundColor: Colors.yellow[700],
),
Expand All @@ -33,8 +51,8 @@ class _ProfileState extends State<Profile> {
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0),
child: ListView(
children: const [
//Afterwards, it should be modified to take an ID as input and retrieve data based on that ID.
//Alternatively, the outer layer retrieves all the data for the cards and inserts them individually.
// Afterwards, it should be modified to take an ID as input and retrieve data based on that ID.
// Alternatively, the outer layer retrieves all the data for the cards and inserts them individually.
ProfileUserCard(
name: 'Addison',
age: 18,
Expand Down
Loading
Loading