pull/1/head
张萌 3 years ago
commit 75f26e708a

@ -17,6 +17,7 @@ import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -73,7 +74,9 @@ class _PersonalIndexState extends State<PersonalIndex>
final double _statusHeight = MediaQuery.of(context).padding.top; final double _statusHeight = MediaQuery.of(context).padding.top;
final userProvider = Provider.of<UserProvider>(context); final userProvider = Provider.of<UserProvider>(context);
return Scaffold( return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.dark,
child:Scaffold(
body: EasyRefresh( body: EasyRefresh(
header: MaterialHeader(), header: MaterialHeader(),
onRefresh: () async { onRefresh: () async {
@ -399,7 +402,9 @@ class _PersonalIndexState extends State<PersonalIndex>
), ),
], ],
)), )),
)
); );
} }
_homeTitle(String title, VoidCallback onTap, String suffixTitle) { _homeTitle(String title, VoidCallback onTap, String suffixTitle) {

@ -16,6 +16,7 @@ import 'package:aku_new_community/ui/community/community_views/my_community_view
import 'package:aku_new_community/ui/community/community_views/new_community_view.dart'; import 'package:aku_new_community/ui/community/community_views/new_community_view.dart';
import 'package:aku_new_community/ui/community/community_views/topic/topic_community_view.dart'; import 'package:aku_new_community/ui/community/community_views/topic/topic_community_view.dart';
import 'package:aku_new_community/ui/community/community_views/widgets/chat_card.dart'; import 'package:aku_new_community/ui/community/community_views/widgets/chat_card.dart';
import 'package:aku_new_community/ui/home/public_infomation/public_infomation_card.dart';
import 'package:aku_new_community/ui/home/public_infomation/public_infomation_page.dart'; import 'package:aku_new_community/ui/home/public_infomation/public_infomation_page.dart';
import 'package:aku_new_community/ui/home/public_infomation/public_information_detail_page.dart'; import 'package:aku_new_community/ui/home/public_infomation/public_information_detail_page.dart';
import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/utils/headers.dart';
@ -87,7 +88,7 @@ class _CommunityPageState extends State<CommunityPage>
final appProvider = Provider.of<AppProvider>(context); final appProvider = Provider.of<AppProvider>(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
titleSpacing: 10.0, titleSpacing: 0,
title: Align( title: Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Theme( child: Theme(
@ -364,7 +365,7 @@ class _CommunityPageState extends State<CommunityPage>
), ),
Spacer(), Spacer(),
Text( Text(
DateUtil.formatDateStr(item.createDate,format: 'MM-dd'), RelativeDateFormat.format(item.createDate.toDate()),
maxLines: 2, maxLines: 2,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(

@ -273,6 +273,7 @@ class _ChatCardState extends State<ChatCard> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
32.hb, 32.hb,
if(!widget.model.content!.isEmptyOrNull)
widget.model.content!.text.size(32.sp).black.make(), widget.model.content!.text.size(32.sp).black.make(),
32.hb, 32.hb,
_renderImage(), _renderImage(),

@ -156,6 +156,7 @@ class _ChatCardDetailState extends State<ChatCardDetail> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
32.hb, 32.hb,
if(!widget.model.content!.isEmptyOrNull)
widget.model.content!.text widget.model.content!.text
.size(28.sp) .size(28.sp)
.color(ktextSubColor) .color(ktextSubColor)

@ -42,10 +42,7 @@ class PublicInfomationCard extends StatelessWidget {
children: [ children: [
// Text('测试'), // Text('测试'),
Spacer(), Spacer(),
Text('发布于 ${DateUtil.formatDate( Text('发布于 ${RelativeDateFormat.format(model.createDateDT)}'),
model.createDateDT,
format: 'yyyy-MM-dd HH:mm',
)}'),
], ],
), ),
), ),
@ -64,3 +61,73 @@ class PublicInfomationCard extends StatelessWidget {
); );
} }
} }
class RelativeDateFormat {
static final num ONE_MINUTE = 60000;
static final num ONE_HOUR = 3600000;
static final num ONE_DAY = 86400000;
static final num ONE_WEEK = 604800000;
static final String ONE_SECOND_AGO = "秒前";
static final String ONE_MINUTE_AGO = "分钟前";
static final String ONE_HOUR_AGO = "小时前";
static final String ONE_DAY_AGO = "天前";
static final String ONE_MONTH_AGO = "月前";
static final String ONE_YEAR_AGO = "年前";
//
static String format(DateTime? date) {
num delta = DateTime.now().millisecondsSinceEpoch - date!.millisecondsSinceEpoch;
if (delta < 1 * ONE_MINUTE) {
num seconds = toSeconds(delta);
return (seconds <= 0 ? 1 : seconds).toInt().toString() + ONE_SECOND_AGO;
}
if (delta < 60 * ONE_MINUTE) {
num minutes = toMinutes(delta);
return (minutes <= 0 ? 1 : minutes).toInt().toString() + ONE_MINUTE_AGO;
}
if (delta < 24 * ONE_HOUR) {
num hours = toHours(delta);
return (hours <= 0 ? 1 : hours).toInt().toString() + ONE_HOUR_AGO;
}
if (delta < 48 * ONE_HOUR) {
return "昨天";
}
if (delta < 30 * ONE_DAY) {
num days = toDays(delta);
return (days <= 0 ? 1 : days).toInt().toString() + ONE_DAY_AGO;
}
if (delta < 12 * 4 * ONE_WEEK) {
num months = toMonths(delta);
return (months <= 0 ? 1 : months).toInt().toString() + ONE_MONTH_AGO;
} else {
num years = toYears(delta);
return (years <= 0 ? 1 : years).toInt().toString() + ONE_YEAR_AGO;
}
}
static num toSeconds(num date) {
return date / 1000;
}
static num toMinutes(num date) {
return toSeconds(date) / 60;
}
static num toHours(num date) {
return toMinutes(date) / 60;
}
static num toDays(num date) {
return toHours(date) / 24;
}
static num toMonths(num date) {
return toDays(date) / 30;
}
static num toYears(num date) {
return toMonths(date) / 365;
}
}

Loading…
Cancel
Save