mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-18 18:14:21 +01:00
some code about history
This commit is contained in:
123
lib/component/url_list_item_componnet.dart
Normal file
123
lib/component/url_list_item_componnet.dart
Normal file
@@ -0,0 +1,123 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nowser/component/image_component.dart';
|
||||
import 'package:nowser/const/base.dart';
|
||||
|
||||
class UrlListItemComponnet extends StatefulWidget {
|
||||
String? image;
|
||||
|
||||
String title;
|
||||
|
||||
String url;
|
||||
|
||||
int? dateTime;
|
||||
|
||||
UrlListItemComponnet({
|
||||
this.image,
|
||||
required this.title,
|
||||
required this.url,
|
||||
this.dateTime,
|
||||
});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _UrlListItemComponnet();
|
||||
}
|
||||
}
|
||||
|
||||
class _UrlListItemComponnet extends State<UrlListItemComponnet> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var themeData = Theme.of(context);
|
||||
var smallFontSize = themeData.textTheme.bodySmall!.fontSize;
|
||||
|
||||
Widget iconWidget = Icon(
|
||||
Icons.image,
|
||||
weight: 60,
|
||||
);
|
||||
if (widget.image != null) {
|
||||
iconWidget = ImageComponent(
|
||||
imageUrl: widget.image!,
|
||||
width: 36,
|
||||
height: 36,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
}
|
||||
|
||||
String host = widget.url;
|
||||
try {
|
||||
var uri = Uri.parse(widget.url);
|
||||
host = uri.host;
|
||||
} catch (e) {}
|
||||
|
||||
String time = "";
|
||||
if (widget.dateTime != null) {
|
||||
var dt = DateTime.fromMillisecondsSinceEpoch(widget.dateTime! * 1000);
|
||||
time = "${dt.hour}:${dt.minute}";
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: Base.BASE_PADDING,
|
||||
right: Base.BASE_PADDING,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
alignment: Alignment.center,
|
||||
child: iconWidget,
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
width: 1, color: themeData.hintColor.withOpacity(0.5)),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Base.BASE_PADDING_HALF,
|
||||
bottom: Base.BASE_PADDING_HALF,
|
||||
),
|
||||
padding: EdgeInsets.only(right: Base.BASE_PADDING_HALF),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
host,
|
||||
style: TextStyle(
|
||||
fontSize: smallFontSize,
|
||||
color: themeData.hintColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
child: Text(
|
||||
time,
|
||||
style: TextStyle(
|
||||
color: themeData.hintColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user