11import '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
45class 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 );
0 commit comments