Skip to content

Commit

Permalink
fix: yesod detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Oct 22, 2023
1 parent 1d06c27 commit 712e51d
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 74 deletions.
12 changes: 4 additions & 8 deletions lib/view/pages/yesod/yesod_config_add/first_stage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,15 @@ class YesodAddFirstStage extends StatelessWidget {
},
),
if (state.loadState == LoadState.loading)
const Expanded(
child: Center(
child: CircularProgressIndicator(),
),
const Center(
child: CircularProgressIndicator(),
),
const SizedBox(
height: 16,
),
if (state.loadState == LoadState.failure)
Expanded(
child: Center(
child: Text(state.errorMessage),
),
Center(
child: Text(state.errorMessage),
),
if (state is YesodAddFirstState && state.example != null)
YesodPreviewCard(
Expand Down
22 changes: 11 additions & 11 deletions lib/view/pages/yesod/yesod_config_add/yesod_config_add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ class YesodConfigAdd extends StatelessWidget {
);
},
child: const Text('预览')),
if (state is YesodAddFirstState)
if (state is! YesodAddSecondState)
ElevatedButton(
onPressed: state.loadState == LoadState.loading
? null
: () {
context.read<YesodAddBloc>().add(
YesodAddSecondStageEvent(
state.example?.subscription.title ?? '',
state.url,
),
);
},
onPressed: () {
context.read<YesodAddBloc>().add(
YesodAddSecondStageEvent(
state is YesodAddFirstState
? state.example?.subscription.title ?? ''
: '',
state.url,
),
);
},
child: const Text('下一步'),
),
if (state is YesodAddSecondState)
Expand Down
121 changes: 66 additions & 55 deletions lib/view/pages/yesod/yesod_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ class YesodDetailPage extends StatefulWidget {
}

class _YesodDetailPageState extends State<YesodDetailPage> {
bool initialized = false;
late FeedItem item;

@override
void initState() {
super.initState();
item = FeedItem();
unawaited(GetIt.I<YesodRepo>()
.getFeedItem(widget.itemId)
.then((value) => item = value));
unawaited(GetIt.I<YesodRepo>().getFeedItem(widget.itemId).then((value) {
setState(() {
item = value;
initialized = true;
});
}));
}

late FeedItem item;

@override
Widget build(BuildContext context) {
return DecoratedBox(
Expand All @@ -45,62 +49,69 @@ class _YesodDetailPageState extends State<YesodDetailPage> {
ClipRRect(
borderRadius: SpacingHelper.defaultBorderRadius,
child: AppBar(
title: Text(item.title),
title: Text(initialized ? item.title : '加载中...'),
),
),
Expanded(
child: DynMouseScroll(
builder: (context, controller, physics) {
return SingleChildScrollView(
controller: controller,
physics: physics,
child: BootstrapContainer(
children: [
BootstrapColumn(
xxs: 12,
sm: 10,
md: 8,
child: Container(
padding: const EdgeInsets.all(16),
alignment: Alignment.topCenter,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 16,
),
Row(
children: [
const Text('作者:'),
for (final author in item.authors)
Text(author.name),
],
),
Text(
'发布时间:${DurationHelper.recentString(item.publishedParsed.toDateTime())}'),
if (item.updatedParsed
.toDateTime()
.isAfter(item.publishedParsed.toDateTime()))
if (initialized)
Expanded(
child: DynMouseScroll(
builder: (context, controller, physics) {
return SingleChildScrollView(
controller: controller,
physics: physics,
child: BootstrapContainer(
children: [
BootstrapColumn(
xxs: 12,
sm: 10,
md: 8,
child: Container(
padding: const EdgeInsets.all(16),
alignment: Alignment.topCenter,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 16,
),
Row(
children: [
const Text('作者:'),
for (final author in item.authors)
Text(author.name),
],
),
Text(
'更新时间:${DurationHelper.recentString(item.updatedParsed.toDateTime())}'),
const SizedBox(
height: 16,
),
HtmlWidget(
item.description,
renderMode: RenderMode.column,
enableCaching: true,
),
],
'发布时间:${DurationHelper.recentString(item.publishedParsed.toDateTime())}'),
if (item.updatedParsed
.toDateTime()
.isAfter(item.publishedParsed.toDateTime()))
Text(
'更新时间:${DurationHelper.recentString(item.updatedParsed.toDateTime())}'),
const SizedBox(
height: 16,
),
HtmlWidget(
item.content.isNotEmpty
? item.content
: item.description,
renderMode: RenderMode.column,
enableCaching: true,
),
],
),
),
),
),
],
),
);
},
],
),
);
},
),
)
else
const Center(
child: CircularProgressIndicator(),
),
),
],
),
);
Expand Down

0 comments on commit 712e51d

Please sign in to comment.