Skip to content

Commit 4870831

Browse files
committed
show details done
1 parent bb202d8 commit 4870831

File tree

14 files changed

+110
-104
lines changed

14 files changed

+110
-104
lines changed

backend/models/url.models.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const mongoose = require('mongoose');
2-
const User = require('./user.models.js');
3-
const { isPassportNumber } = require('validator');
42

53
const urlSchema = new mongoose.Schema({
64
shortId: {

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ejs": "^3.1.10",
1919
"express": "^4.21.2",
2020
"jsonwebtoken": "^9.0.2",
21-
"mongoose": "^8.9.2",
21+
"mongoose": "^8.19.1",
2222
"passport": "^0.7.0",
2323
"passport-github2": "^0.1.12",
2424
"passport-google-oauth20": "^2.0.0",

backend/pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flutter_app/lib/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_app/screens/details.screen.dart';
32
import 'package:flutter_app/screens/home_screen.dart';
43
import 'package:flutter_app/screens/urls_screen.dart';
54
import 'screens/login_screen.dart';
@@ -26,7 +25,6 @@ class MyApp extends StatelessWidget {
2625
'/login': (context) => const LoginScreen(),
2726
'/signup': (context) => const SignupScreen(),
2827
'/home': (context) => const HomeScreen(),
29-
'/details': (context) => const DetailsScreen(longUrl: "hello", shortUrl: "https://sunjay.xyz/abc123"),
3028
'/urls': (context) => const UrlsScreen()
3129
},
3230
);

flutter_app/lib/screens/details.screen.dart

Lines changed: 38 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/services.dart';
2+
import 'package:flutter_app/widgets/copy_container.dart';
3+
import 'package:flutter_app/widgets/visit_history_table.dart';
34

45
class DetailsScreen extends StatelessWidget {
5-
final String longUrl;
6-
final String shortUrl;
6+
final Map<String, dynamic> url;
77

8-
const DetailsScreen({
9-
super.key,
10-
required this.longUrl,
11-
required this.shortUrl,
12-
});
8+
const DetailsScreen({super.key, required this.url});
139

1410
@override
1511
Widget build(BuildContext context) {
@@ -22,65 +18,45 @@ class DetailsScreen extends StatelessWidget {
2218
),
2319
body: Padding(
2420
padding: const EdgeInsets.all(20),
25-
child: Column(
26-
crossAxisAlignment: CrossAxisAlignment.stretch,
27-
children: [
28-
const SizedBox(height: 20),
29-
const Text(
30-
"Original URL:",
31-
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
32-
),
33-
const SizedBox(height: 8),
34-
Container(
35-
padding: const EdgeInsets.all(12),
36-
decoration: BoxDecoration(
37-
color: Colors.grey[100],
38-
borderRadius: BorderRadius.circular(10),
21+
child: SingleChildScrollView(
22+
child: Column(
23+
crossAxisAlignment: CrossAxisAlignment.stretch,
24+
children: [
25+
const SizedBox(height: 20),
26+
const Text(
27+
"Original URL:",
28+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
3929
),
40-
child: Text(
41-
longUrl,
42-
style: const TextStyle(color: Colors.black87),
30+
const SizedBox(height: 8),
31+
CopyContainer(url: url["redirectUrl"]),
32+
33+
const SizedBox(height: 30),
34+
const Text(
35+
"Shortened URL:",
36+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
4337
),
44-
),
45-
const SizedBox(height: 30),
46-
const Text(
47-
"Shortened URL:",
48-
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
49-
),
50-
const SizedBox(height: 8),
51-
Container(
52-
padding: const EdgeInsets.all(8),
53-
decoration: BoxDecoration(
54-
color: Colors.grey[100],
55-
borderRadius: BorderRadius.circular(10),
38+
const SizedBox(height: 8),
39+
CopyContainer(url: "https://sunjay.xyz/${url["shortId"]}"),
40+
41+
const SizedBox(height: 30),
42+
const Text(
43+
"Visit History:",
44+
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
5645
),
57-
child: Row(
58-
children: [
59-
Expanded(
60-
child: Text(
61-
shortUrl,
62-
style: const TextStyle(
63-
color: Colors.black,
64-
fontWeight: FontWeight.w500,
65-
),
66-
),
67-
),
68-
IconButton(
69-
onPressed: () {
70-
Clipboard.setData(ClipboardData(text: shortUrl));
71-
ScaffoldMessenger.of(context).showSnackBar(
72-
const SnackBar(
73-
content: Text("Short URL copied!"),
74-
duration: Duration(seconds: 1),
75-
),
76-
);
77-
},
78-
icon: const Icon(Icons.copy, color: Color(0xffffbf00)),
46+
const SizedBox(height: 8),
47+
48+
// Table with fixed height and horizontal scrolling
49+
SizedBox(
50+
height: 300, // adjust as needed
51+
child: SingleChildScrollView(
52+
scrollDirection: Axis.horizontal,
53+
child: VisitHistoryTable(
54+
visitHistory: url['visitHistory'] ?? [],
7955
),
80-
],
56+
),
8157
),
82-
),
83-
],
58+
],
59+
),
8460
),
8561
),
8662
);

flutter_app/lib/screens/home_screen.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:convert';
2-
32
import 'package:flutter/material.dart';
43
import 'package:flutter_app/widgets/copy_container.dart';
54
import 'package:flutter_app/widgets/app_drawer.dart';
@@ -194,7 +193,7 @@ class _HomeScreenState extends State<HomeScreen> {
194193

195194
SizedBox(height: 20),
196195

197-
if (shortUrl != null) CopyContainer(shortUrl: shortUrl!),
196+
if (shortUrl != null) CopyContainer(url: shortUrl!),
198197
],
199198
),
200199
),

flutter_app/lib/screens/login_screen.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class _LoginScreenState extends State<LoginScreen> {
2929

3030
void checkToken() async {
3131
final token = await getToken();
32-
print(token);
3332
if (token != null && token.isNotEmpty) {
3433
Navigator.pushReplacementNamed(context, '/home');
3534
}
@@ -73,11 +72,6 @@ class _LoginScreenState extends State<LoginScreen> {
7372
}
7473
}
7574

76-
void handleGoogleLogin() {
77-
print('Login with Google');
78-
// TODO: open your backend Google auth URL with flutter_web_auth
79-
}
80-
8175
@override
8276
Widget build(BuildContext context) {
8377
return Scaffold(
@@ -148,15 +142,6 @@ class _LoginScreenState extends State<LoginScreen> {
148142
child: Text('Login'),
149143
),
150144

151-
SizedBox(height: 10),
152-
OutlinedButton(
153-
onPressed: handleGoogleLogin,
154-
style: OutlinedButton.styleFrom(
155-
minimumSize: Size(double.infinity, 50),
156-
),
157-
child: Text('Continue with Google'),
158-
),
159-
160145
SizedBox(height: 10),
161146

162147
TextButton(

flutter_app/lib/screens/urls_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:convert';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_app/widgets/app_drawer.dart';
4-
import 'package:flutter_app/widgets/urlListTile.dart';
4+
import 'package:flutter_app/widgets/url_list_tile.dart';
55
import 'package:shared_preferences/shared_preferences.dart';
66
import 'package:http/http.dart' as http;
77

flutter_app/lib/widgets/app_drawer.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ class AppDrawer extends StatelessWidget {
4040
},
4141
),
4242

43-
ListTile(
44-
leading: const Icon(Icons.insert_chart),
45-
title: const Text("Details"),
46-
onTap: () {
47-
Navigator.pop(context);
48-
Navigator.pushNamed(context, '/details');
49-
},
50-
),
51-
5243
const Divider(),
5344

5445
ListTile(

flutter_app/lib/widgets/copy_container.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
22
import 'package:flutter/services.dart';
33

44
class CopyContainer extends StatelessWidget {
5-
final String shortUrl;
5+
final String url;
66

7-
const CopyContainer({super.key, required this.shortUrl});
7+
const CopyContainer({super.key, required this.url});
88

99
@override
1010
Widget build(BuildContext context) {
@@ -18,7 +18,7 @@ class CopyContainer extends StatelessWidget {
1818
children: [
1919
Expanded(
2020
child: Text(
21-
shortUrl,
21+
url,
2222
style: const TextStyle(
2323
color: Colors.black,
2424
fontWeight: FontWeight.w500,
@@ -27,7 +27,7 @@ class CopyContainer extends StatelessWidget {
2727
),
2828
IconButton(
2929
onPressed: () {
30-
Clipboard.setData(ClipboardData(text: shortUrl));
30+
Clipboard.setData(ClipboardData(text: url));
3131
ScaffoldMessenger.of(context).showSnackBar(
3232
const SnackBar(
3333
content: Text("Short URL copied!"),

0 commit comments

Comments
 (0)