Skip to content

Commit 15626ae

Browse files
committed
minor updates
1 parent b85aa12 commit 15626ae

10 files changed

Lines changed: 96 additions & 119 deletions

22SW050_71_MAD_CEP.pdf

-177 KB
Binary file not shown.

flutter_app/analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
# The following line activates a set of recommended lints for Flutter apps,
99
# packages, and plugins designed to encourage good coding practices.
10+
analyzer:
11+
errors:
12+
use_build_context_synchronously: ignore
1013
include: package:flutter_lints/flutter.yaml
1114

1215
linter:

flutter_app/lib/screens/details.screen.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DetailsScreen extends StatelessWidget {
3636
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
3737
),
3838
const SizedBox(height: 8),
39-
CopyContainer(url: "https://sunjay.xyz/${url["shortId"]}"),
39+
CopyContainer(url: "http://localhost:9000/${url["shortId"]}"),
4040

4141
const SizedBox(height: 30),
4242
const Text(
@@ -45,9 +45,8 @@ class DetailsScreen extends StatelessWidget {
4545
),
4646
const SizedBox(height: 8),
4747

48-
// Table with fixed height and horizontal scrolling
4948
SizedBox(
50-
height: 300, // adjust as needed
49+
height: 300,
5150
child: SingleChildScrollView(
5251
scrollDirection: Axis.horizontal,
5352
child: VisitHistoryTable(

flutter_app/lib/screens/home_screen.dart

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class _HomeScreenState extends State<HomeScreen> {
4848

4949
try {
5050
final response = await http.post(
51-
Uri.parse('https://go.sunjay.xyz/'),
51+
Uri.parse('http://localhost:9000/'),
5252
headers: {
5353
'Content-Type': 'application/json',
5454
'authorization': 'Bearer ${prefs.getString('JWT_TOKEN')}',
@@ -59,7 +59,7 @@ class _HomeScreenState extends State<HomeScreen> {
5959
final data = jsonDecode(response.body);
6060
if (response.statusCode == 200) {
6161
setState(() {
62-
shortUrl = "https://go.sunjay.xyz/${data["new"]}";
62+
shortUrl = "http://localhost:9000/${data["new"]}";
6363
});
6464
_urlController.clear();
6565
_aliasController.clear();
@@ -118,7 +118,6 @@ class _HomeScreenState extends State<HomeScreen> {
118118

119119
Row(
120120
children: [
121-
// Left Input (Readonly URL)
122121
Expanded(
123122
flex: 3,
124123
child: Container(
@@ -136,14 +135,13 @@ class _HomeScreenState extends State<HomeScreen> {
136135
vertical: 10,
137136
),
138137
child: Text(
139-
"https://go.sunjay.xyz/",
138+
"http://localhost:9000/",
140139
style: TextStyle(fontSize: 16),
141140
),
142141
),
143142
),
144143
),
145144

146-
// Right Input (Alias)
147145
Expanded(
148146
flex: 2,
149147
child: TextFormField(
@@ -161,15 +159,6 @@ class _HomeScreenState extends State<HomeScreen> {
161159
bottomRight: Radius.circular(8),
162160
),
163161
),
164-
focusedBorder: OutlineInputBorder(
165-
borderSide: const BorderSide(
166-
width: 2,
167-
),
168-
borderRadius: const BorderRadius.only(
169-
topRight: Radius.circular(8),
170-
bottomRight: Radius.circular(8),
171-
),
172-
),
173162
),
174163
),
175164
),

flutter_app/lib/screens/login_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class _LoginScreenState extends State<LoginScreen> {
4343

4444
try {
4545
final response = await http.post(
46-
Uri.parse('https://go.sunjay.xyz/user/login'),
46+
Uri.parse('http://localhost:9000/user/login'),
4747
headers: {'Content-Type': 'application/json'},
4848
body: jsonEncode({'email': email, 'password': password}),
4949
);

flutter_app/lib/screens/signup_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class _SignupScreenState extends State<SignupScreen> {
4747

4848
try {
4949
final response = await http.post(
50-
Uri.parse('https://go.sunjay.xyz/user/signup'),
50+
Uri.parse('http://localhost:9000/user/signup'),
5151
headers: {'Content-Type': 'application/json'},
5252
body: jsonEncode({
5353
'username': userName,

flutter_app/lib/screens/urls_screen.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ class _UrlsScreenState extends State<UrlsScreen> {
1616
@override
1717
void initState() {
1818
super.initState();
19-
_checkToken();
19+
checkToken();
2020
}
2121

22-
Future<String?> _getToken() async {
22+
Future<String?> getToken() async {
2323
final prefs = await SharedPreferences.getInstance();
2424
return prefs.getString('JWT_TOKEN');
2525
}
2626

27-
void _checkToken() async {
28-
final token = await _getToken();
27+
void checkToken() async {
28+
final token = await getToken();
2929

3030
if (token == null || token.isEmpty) {
3131
if (mounted) {
@@ -74,7 +74,7 @@ class UrlListSection extends StatelessWidget {
7474

7575
try {
7676
final response = await http.get(
77-
Uri.parse('https://go.sunjay.xyz/api/userUrls/'),
77+
Uri.parse('http://localhost:9000/api/userUrls/'),
7878
headers: {
7979
'Content-Type': 'application/json',
8080
'Authorization': 'Bearer $token',

flutter_app/lib/widgets/app_drawer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:shared_preferences/shared_preferences.dart';
44
class AppDrawer extends StatelessWidget {
55
const AppDrawer({super.key});
66

7-
Future<void> _handleLogout(BuildContext context) async {
7+
Future<void> handleLogout(BuildContext context) async {
88
final prefs = await SharedPreferences.getInstance();
99
await prefs.remove('JWT_TOKEN');
1010

@@ -45,7 +45,7 @@ class AppDrawer extends StatelessWidget {
4545
ListTile(
4646
leading: const Icon(Icons.logout),
4747
title: const Text("Logout"),
48-
onTap: () => _handleLogout(context),
48+
onTap: () => handleLogout(context),
4949
),
5050
],
5151
),

flutter_app/lib/widgets/url_list_tile.dart

Lines changed: 49 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,66 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_app/screens/details.screen.dart';
33

44
class UrlListTile extends StatelessWidget {
5-
final Map<String, dynamic> url;
5+
final Map<String, dynamic> url;
66

77
const UrlListTile({super.key, required this.url});
88

99
@override
1010
Widget build(BuildContext context) {
11-
final name = url['name'];
12-
final shortUrl = url['shortId'];
13-
final createdAt = url['createdAt'];
14-
final visitHistory = url['visitHistory'] ?? [];
15-
final clicks = visitHistory.length;
11+
final String name = url['name'];
12+
final String shortUrl = url['shortId'];
13+
final String createdAt = url['createdAt'];
14+
final List<dynamic> visitHistory = url['visitHistory'] ?? [];
15+
final int clicks = visitHistory.length;
1616

1717
return Card(
18-
color: Colors.white,
19-
elevation: 2,
20-
child: InkWell(
21-
borderRadius: BorderRadius.circular(10),
22-
onTap: () {
23-
Navigator.push(
24-
context,
25-
MaterialPageRoute(
26-
builder: (context) => DetailsScreen(url: url),
27-
),
28-
);
29-
},
30-
child: Padding(
31-
padding: const EdgeInsets.all(12),
32-
child: Column(
33-
crossAxisAlignment: CrossAxisAlignment.start,
34-
children: [
35-
Row(
36-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
37-
children: [
38-
Text(
39-
'🔗 $name',
40-
style: const TextStyle(
41-
fontSize: 16,
42-
fontWeight: FontWeight.w600,
43-
color: Colors.black87,
44-
),
45-
),
46-
Text(
47-
createdAt,
48-
style: const TextStyle(fontSize: 12, color: Colors.grey),
49-
),
50-
],
51-
),
18+
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
19+
20+
child: ListTile(
21+
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
22+
23+
leading: const Icon(Icons.link),
24+
25+
title: Text(
26+
name,
27+
style: const TextStyle(
28+
fontSize: 16,
29+
fontWeight: FontWeight.w600,
30+
color: Colors.black87,
31+
),
32+
),
5233

53-
const SizedBox(height: 6),
34+
subtitle: Column(
35+
crossAxisAlignment: CrossAxisAlignment.start,
36+
children: [
37+
const SizedBox(height: 4),
38+
Text(
39+
shortUrl,
40+
style: const TextStyle(color: Colors.blueAccent),
41+
),
42+
const SizedBox(height: 4),
43+
Text(
44+
createdAt,
45+
style: const TextStyle(fontSize: 12, color: Colors.grey),
46+
),
47+
],
48+
),
5449

55-
Row(
56-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
57-
children: [
58-
Text(shortUrl),
59-
Row(
60-
children: [
61-
Icon(Icons.ads_click_outlined),
62-
const SizedBox(width: 4),
63-
Text('$clicks'),
64-
],
65-
),
66-
],
67-
),
68-
],
50+
trailing: Row(
51+
mainAxisSize: MainAxisSize.min,
52+
children: [
53+
const Icon(Icons.ads_click_outlined, size: 20),
54+
const SizedBox(width: 4),
55+
Text('$clicks'),
56+
],
57+
),
58+
onTap: () => Navigator.push(
59+
context,
60+
MaterialPageRoute(
61+
builder: (_) => DetailsScreen(url: url),
6962
),
7063
),
7164
),
7265
);
7366
}
74-
}
67+
}

flutter_app/lib/widgets/visit_history_table.dart

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,39 @@ class VisitHistoryTable extends StatelessWidget {
99
@override
1010
Widget build(BuildContext context) {
1111
if (visitHistory.isEmpty) {
12-
return const Center(
13-
child: Text("No visit history found"),
14-
);
12+
return Center(child: Text("No visit history found"));
1513
}
1614

17-
return SizedBox(
18-
height: 300,
19-
child: SingleChildScrollView(
20-
scrollDirection: Axis.horizontal,
21-
child: DataTable(
22-
columns: const [
23-
DataColumn(label: Text('Date')),
24-
DataColumn(label: Text('IP Address')),
25-
DataColumn(label: Text('Browser')),
26-
DataColumn(label: Text('OS')),
27-
DataColumn(label: Text('Device')),
28-
DataColumn(label: Text('Country')),
29-
DataColumn(label: Text('City')),
30-
DataColumn(label: Text('Region')),
31-
],
32-
rows: visitHistory.map((visit) {
33-
final timestamp = visit['timestamps'] ?? 0;
34-
final formattedDate = DateFormat('dd/MM/yyyy, HH:mm:ss')
35-
.format(DateTime.fromMillisecondsSinceEpoch(timestamp));
15+
return DataTable(
16+
columns: [
17+
DataColumn(label: Text('Date')),
18+
DataColumn(label: Text('IP Address')),
19+
DataColumn(label: Text('Browser')),
20+
DataColumn(label: Text('OS')),
21+
DataColumn(label: Text('Device')),
22+
DataColumn(label: Text('Country')),
23+
DataColumn(label: Text('City')),
24+
DataColumn(label: Text('Region')),
25+
],
26+
rows: visitHistory.map((visit) {
27+
final timestamp = visit['timestamps'] ?? 0;
28+
final formattedDate = DateFormat(
29+
'dd/MM/yyyy, HH:mm:ss',
30+
).format(DateTime.fromMillisecondsSinceEpoch(timestamp));
3631

37-
return DataRow(
38-
cells: [
39-
DataCell(Text(formattedDate)),
40-
DataCell(Text(visit['ipaddress'] ?? 'Unknown')),
41-
DataCell(Text(visit['browser'] ?? 'Unknown')),
42-
DataCell(Text(visit['os'] ?? 'Unknown')),
43-
DataCell(Text(visit['device'] ?? 'Unknown')),
44-
DataCell(Text(visit['country'] ?? 'Unknown')),
45-
DataCell(Text(visit['city'] ?? 'Unknown')),
46-
DataCell(Text(visit['region'] ?? 'Unknown')),
47-
],
48-
);
49-
}).toList(),
50-
),
51-
),
32+
return DataRow(
33+
cells: [
34+
DataCell(Text(formattedDate)),
35+
DataCell(Text(visit['ipaddress'] ?? 'Unknown')),
36+
DataCell(Text(visit['browser'] ?? 'Unknown')),
37+
DataCell(Text(visit['os'] ?? 'Unknown')),
38+
DataCell(Text(visit['device'] ?? 'Unknown')),
39+
DataCell(Text(visit['country'] ?? 'Unknown')),
40+
DataCell(Text(visit['city'] ?? 'Unknown')),
41+
DataCell(Text(visit['region'] ?? 'Unknown')),
42+
],
43+
);
44+
}).toList(),
5245
);
5346
}
5447
}

0 commit comments

Comments
 (0)