Skip to content

Commit

Permalink
feat(history): update thread visit history page layout
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Oct 4, 2024
1 parent 05603a2 commit 0a604ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:tsdm_client/features/thread_visit_history/widgets/thread_visit_h
import 'package:tsdm_client/i18n/strings.g.dart';
import 'package:tsdm_client/shared/models/models.dart';
import 'package:tsdm_client/utils/retry_button.dart';
import 'package:tsdm_client/widgets/tips.dart';

/// Page of thread visit history.
class ThreadVisitHistoryPage extends StatefulWidget {
Expand All @@ -30,17 +31,7 @@ class _ThreadVisitHistoryPageState extends State<ThreadVisitHistoryPage> {
final body = switch (state.status) {
ThreadVisitHistoryStatus.initial ||
ThreadVisitHistoryStatus.loadingData =>
Column(
children: [
ListTile(
leading: const Icon(Icons.info_outline),
title: Text(tr.localOnlyTip),
),
const Expanded(
child: Center(child: CircularProgressIndicator()),
),
],
),
const Center(child: CircularProgressIndicator()),
ThreadVisitHistoryStatus.savingData ||
ThreadVisitHistoryStatus.success =>
_Body(state.history),
Expand All @@ -58,7 +49,15 @@ class _ThreadVisitHistoryPageState extends State<ThreadVisitHistoryPage> {
),
body: AnimatedSwitcher(
duration: duration200,
child: body,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxW4H4,
Tips(tr.localOnlyTip),
sizedBoxW4H4,
Expanded(child: body),
],
),
),
);
},
Expand Down Expand Up @@ -94,7 +93,6 @@ class _BodyState extends State<_Body> {

@override
Widget build(BuildContext context) {
final tr = context.t.threadVisitHistoryPage;
return EasyRefresh.builder(
controller: _refreshController,
scrollController: _scrollController,
Expand All @@ -103,25 +101,15 @@ class _BodyState extends State<_Body> {
.read<ThreadVisitHistoryBloc>()
.add(const ThreadVisitHistoryFetchAllRequested()),
childBuilder: (context, physics) {
return Column(
children: [
ListTile(
leading: const Icon(Icons.info_outline),
title: Text(tr.localOnlyTip),
),
Expanded(
child: ListView.separated(
controller: _scrollController,
physics: physics,
padding: edgeInsetsL12R12,
itemCount: widget.models.length,
itemBuilder: (context, index) {
return ThreadVisitHistoryCard(widget.models[index]);
},
separatorBuilder: (_, __) => sizedBoxW4H4,
),
),
],
return ListView.separated(
controller: _scrollController,
physics: physics,
padding: edgeInsetsL12R12,
itemCount: widget.models.length,
itemBuilder: (context, index) {
return ThreadVisitHistoryCard(widget.models[index]);
},
separatorBuilder: (_, __) => sizedBoxW4H4,
);
},
);
Expand Down
1 change: 0 additions & 1 deletion lib/widgets/tips.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Tips extends StatelessWidget {
Text(
text,
style: Theme.of(context).textTheme.labelMedium?.copyWith(
fontWeight: FontWeight.w100,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
Expand Down

0 comments on commit 0a604ff

Please sign in to comment.