Skip to content

Commit dd973c7

Browse files
fix(settings): Improved Settings UI (#153)
1 parent b54e22b commit dd973c7

33 files changed

Lines changed: 457 additions & 264 deletions

lam7a/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ linter:
2121
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
2222
# producing the lint.
2323
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
24+
avoid_print: false # Uncomment to disable the `avoid_print` rule
2525
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
2626

2727
# Additional information about this file can be found at

lam7a/lib/core/constants/server_constant.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ class ServerConstant {
1616
static String me = "/auth/me";
1717
static String apiPrefix = "/api/v1.0";
1818
static String serverURL = "https://api.hankers.tech";
19+
static String mutedUsers = "/users/mutes/me";
20+
static String blockedUsers = "/users/blocks/me";
1921
}

lam7a/lib/core/providers/authentication.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'package:flutter/material.dart';
2-
import 'package:flutter_riverpod/flutter_riverpod.dart';
31
import 'package:lam7a/core/constants/server_constant.dart';
42
import 'package:lam7a/core/models/auth_state.dart';
53
import 'package:lam7a/core/models/user_model.dart';
@@ -12,7 +10,7 @@ part 'authentication.g.dart';
1210
// this is under developing not finished yet
1311
@Riverpod(keepAlive: true)
1412
class Authentication extends _$Authentication {
15-
late ApiService _apiService;
13+
late ApiService _apiService;
1614
@override
1715
AuthState build() {
1816
_apiService = ref.read(apiServiceProvider);
@@ -44,8 +42,7 @@ class Authentication extends _$Authentication {
4442
if (response['message'] == 'Logout successful') {
4543
prefs.remove('token');
4644
state = state.copyWith(user: null, isAuthenticated: false);
47-
}
48-
else {
45+
} else {
4946
print("Logout failed");
5047
}
5148
} catch (e) {

lam7a/lib/features/authentication/repository/authentication_impl_repository.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import 'dart:convert';
2-
3-
import 'package:flutter_riverpod/flutter_riverpod.dart';
41
import 'package:lam7a/core/models/user_model.dart';
5-
import 'package:lam7a/core/services/api_service.dart';
62
import 'package:lam7a/features/authentication/model/authentication_user_credentials_model.dart';
73
import 'package:lam7a/features/authentication/model/authentication_user_data_model.dart';
84
import 'package:lam7a/features/authentication/service/authentication_api_service.dart';
95
import 'package:lam7a/features/authentication/utils/authentication_constants.dart';
106
import 'package:riverpod_annotation/riverpod_annotation.dart';
117
part 'authentication_impl_repository.g.dart';
8+
129
@riverpod
1310
AuthenticationRepositoryImpl authenticationImplRepository(Ref ref) {
1411
return AuthenticationRepositoryImpl(
@@ -23,17 +20,20 @@ class AuthenticationRepositoryImpl {
2320
Map<String, dynamic> body;
2421
body = await apiService.checkEmail(email);
2522
print(body);
26-
return (body[AuthenticationConstants.message].toString() == AuthenticationConstants.emailExist);
23+
return (body[AuthenticationConstants.message].toString() ==
24+
AuthenticationConstants.emailExist);
2725
}
2826

2927
Future<bool> verificationOTP(String email) async {
3028
final message = await apiService.verificationOTP(email);
31-
return (message[AuthenticationConstants.status].toString() == AuthenticationConstants.success);
29+
return (message[AuthenticationConstants.status].toString() ==
30+
AuthenticationConstants.success);
3231
}
3332

3433
Future<bool> resendOTP(String email) async {
3534
final message = await apiService.resendOTP(email);
36-
return (message[AuthenticationConstants.status].toString() == AuthenticationConstants.success);
35+
return (message[AuthenticationConstants.status].toString() ==
36+
AuthenticationConstants.success);
3737
}
3838

3939
Future<UserModel?> register(AuthenticationUserDataModel user) async {
@@ -44,7 +44,8 @@ class AuthenticationRepositoryImpl {
4444

4545
Future<bool> verifyOTP(String email, String OTP) async {
4646
final message = await apiService.verifyOTP(email, OTP);
47-
return (message[AuthenticationConstants.status].toString() == AuthenticationConstants.success);
47+
return (message[AuthenticationConstants.status].toString() ==
48+
AuthenticationConstants.success);
4849
}
4950

5051
Future<UserModel> login(

lam7a/lib/features/authentication/ui/view/screens/login_screen/authentication_login_screen.dart

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,40 @@ class _loginFlowtate extends State<LogInScreen> {
9494
child: AuthenticationStepButton(
9595
key: ValueKey("loginNextButton"),
9696
enable: viewmodel.shouldEnableNextLogin(),
97-
label: AuthenticationConstants.loginButtonLabels[currentIndex],
98-
bgColor: Theme.of(context).colorScheme.onSurface,
99-
textColor: Theme.of(context).colorScheme.surface,
100-
onPressedEffect: () async{
101-
if (currentIndex == AuthenticationConstants.finishLogin) {
97+
label: AuthenticationConstants
98+
.loginButtonLabels[currentIndex],
99+
bgColor: Theme.of(
100+
context,
101+
).colorScheme.onSurface,
102+
textColor: Theme.of(
103+
context,
104+
).colorScheme.surface,
105+
onPressedEffect: () async {
106+
if (currentIndex ==
107+
AuthenticationConstants.finishLogin) {
102108
await viewmodel.login();
103-
String? message = ref.read(authenticationViewmodelProvider).toastMessageLogin;
104-
if (message != null)
105-
{
106-
AuthenticationConstants.flushMessage(message, context, "loginMessage");
109+
String? message = ref
110+
.read(authenticationViewmodelProvider)
111+
.toastMessageLogin;
112+
if (message != null) {
113+
AuthenticationConstants.flushMessage(
114+
message,
115+
context,
116+
"loginMessage",
117+
);
107118
}
108119
if (authenticationState.isAuthenticated) {
109120
Navigator.pop(context);
110121
// Navigate to transmission screen (after auth page)
111122
Navigator.pushNamedAndRemoveUntil(
112123
context,
113-
AuthenticationTransmissionScreen.routeName,
124+
AuthenticationTransmissionScreen
125+
.routeName,
114126
(route) => false,
115127
);
116128
}
117-
} else if (viewmodel.shouldEnableNextLogin()){
129+
} else if (viewmodel
130+
.shouldEnableNextLogin()) {
118131
viewmodel.gotoNextLoginStep();
119132
}
120133
},
@@ -126,9 +139,7 @@ class _loginFlowtate extends State<LogInScreen> {
126139
),
127140
],
128141
)
129-
: Center(
130-
child: LoadingCircle(),
131-
),
142+
: Center(child: LoadingCircle()),
132143
),
133144
);
134145
},

lam7a/lib/features/authentication/ui/view/screens/login_screen/steps/password_login_step.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
33
import 'package:google_fonts/google_fonts.dart';
44
import 'package:lam7a/core/theme/app_pallete.dart';
55
import 'package:lam7a/features/authentication/ui/viewmodel/authentication_viewmodel.dart';
6-
import 'package:lam7a/features/authentication/ui/widgets/authentication_step_button.dart';
76
import 'package:lam7a/features/authentication/ui/widgets/authentication_text_input_field.dart';
87

98
class PasswordLogin extends StatelessWidget {

lam7a/lib/features/common/dtos/api_response.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:freezed_annotation/freezed_annotation.dart';
2-
import 'package:lam7a/features/messaging/dtos/conversation_dto.dart';
32

43
part 'api_response.freezed.dart';
54
part 'api_response.g.dart';
@@ -18,7 +17,6 @@ abstract class ApiResponse<T> with _$ApiResponse<T> {
1817
) => _$ApiResponseFromJson(json, fromJsonT);
1918
}
2019

21-
2220
class Metadata {
2321
final int totalItems;
2422
final int page;
@@ -33,16 +31,16 @@ class Metadata {
3331
});
3432

3533
factory Metadata.fromJson(Map<String, dynamic> json) => Metadata(
36-
totalItems: json['totalItems'],
37-
page: json['page'],
38-
limit: json['limit'],
39-
totalPages: json['totalPages'],
40-
);
34+
totalItems: json['totalItems'],
35+
page: json['page'],
36+
limit: json['limit'],
37+
totalPages: json['totalPages'],
38+
);
4139

4240
Map<String, dynamic> toJson() => {
43-
'totalItems': totalItems,
44-
'page': page,
45-
'limit': limit,
46-
'totalPages': totalPages,
47-
};
41+
'totalItems': totalItems,
42+
'page': page,
43+
'limit': limit,
44+
'totalPages': totalPages,
45+
};
4846
}

lam7a/lib/features/messaging/repository/conversations_repositories.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ConversationsRepository {
2626

2727
var conversationsDto = await _apiService.getConversations();
2828

29-
var conversations = conversationsDto.data!.map((x) {
29+
var conversations = conversationsDto.data.map((x) {
3030
return Conversation(
3131
id: x.id,
3232
userId: x.user.id,
@@ -41,11 +41,15 @@ class ConversationsRepository {
4141
return conversations;
4242
}
4343

44-
Future<int> getConversationIdByUserId(int userId) async{
44+
Future<int> getConversationIdByUserId(int userId) async {
4545
return await _apiService.createConversation(userId);
4646
}
4747

48-
Future<List<Contact>> searchForContacts(String query, int page, [int limit = 20]) async {
48+
Future<List<Contact>> searchForContacts(
49+
String query,
50+
int page, [
51+
int limit = 20,
52+
]) async {
4953
return await _apiService.searchForContacts(query, page, limit);
5054
}
5155

lam7a/lib/features/navigation/ui/view/navigation_home_screen.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import 'package:lam7a/features/tweet/ui/view/pages/tweet_home_screen.dart';
2121
class NavigationHomeScreen extends StatefulWidget {
2222
static const String routeName = "navigation";
2323

24+
const NavigationHomeScreen({super.key});
25+
2426
@override
2527
State<NavigationHomeScreen> createState() => _NavigationHomeScreenState();
2628
}
@@ -30,7 +32,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
3032
int valueFromDropdown = 0;
3133
bool _isVisible = true;
3234
double _lastOffset = 0;
33-
String? themeMode;
35+
String? themeMode;
3436

3537
@override
3638
Widget build(BuildContext context) {
@@ -374,12 +376,8 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
374376
RadioGroup<String>(
375377
groupValue: themeMode, // Your state variable
376378
onChanged: (value) {
377-
modalSetState(
378-
() => themeMode = value,
379-
);
380-
setState(
381-
() {},
382-
);
379+
modalSetState(() => themeMode = value);
380+
setState(() {});
383381
},
384382
child: Column(
385383
children: [
@@ -414,7 +412,8 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
414412
],
415413
),
416414
),
417-
const SizedBox(height: 16),]
415+
const SizedBox(height: 16),
416+
],
418417
),
419418
),
420419
);

lam7a/lib/features/settings/repository/user_releations_repository.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ part 'user_releations_repository.g.dart';
66

77
@riverpod
88
UserRelationsRepository userRelationsRepository(Ref ref) {
9+
// return UserRelationsRepository(ref.read(usersApiServiceImplProvider));
910
return UserRelationsRepository(ref.read(usersApiServiceProvider));
1011
}
1112

0 commit comments

Comments
 (0)