-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# 更新记录 | ||
## v0.5.1(未发布) | ||
- 可以设置长按历史或订阅/标签按钮会在新标签页打开对应页面(高级设置) | ||
- 长按串的时间会在相对时间和绝对时间之间切换 | ||
- 修复“修复字体显示”无效的问题 | ||
|
||
## v0.5.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:timeago_flutter/timeago_flutter.dart'; | ||
|
||
class TimerRefresher extends TimerRefreshWidget { | ||
class _TimerRefresher extends TimerRefreshWidget { | ||
final WidgetBuilder builder; | ||
|
||
const TimerRefresher({super.key, super.refreshRate, required this.builder}); | ||
// ignore: unused_element | ||
const _TimerRefresher({super.key, super.refreshRate, required this.builder}); | ||
|
||
@override | ||
Widget build(BuildContext context) => builder(context); | ||
} | ||
|
||
class PostTime extends StatefulWidget { | ||
final bool isShowRelativeTime; | ||
|
||
final WidgetBuilder relativeTime; | ||
|
||
final Widget absoluteTime; | ||
|
||
const PostTime( | ||
{super.key, | ||
required this.isShowRelativeTime, | ||
required this.relativeTime, | ||
required this.absoluteTime}); | ||
|
||
@override | ||
State<PostTime> createState() => _PostTimeState(); | ||
} | ||
|
||
class _PostTimeState extends State<PostTime> { | ||
late bool _isShowRelativeTime; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
_isShowRelativeTime = widget.isShowRelativeTime; | ||
} | ||
|
||
@override | ||
void didUpdateWidget(covariant PostTime oldWidget) { | ||
super.didUpdateWidget(oldWidget); | ||
|
||
if (widget.isShowRelativeTime != oldWidget.isShowRelativeTime) { | ||
_isShowRelativeTime = widget.isShowRelativeTime; | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) => GestureDetector( | ||
onLongPress: () => | ||
setState(() => _isShowRelativeTime = !_isShowRelativeTime), | ||
child: _isShowRelativeTime | ||
? _TimerRefresher(builder: widget.relativeTime) | ||
: widget.absoluteTime); | ||
} |