Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: optimize recent page views section UI (#4067)

Richard Shiue5ff6405f7f71
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_home_recent_views.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_home_recent_views.dart
index 7f72ce5f37..65740156fc 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_home_recent_views.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_home_recent_views.dart
@@ -3,8 +3,7 @@ import 'package:appflowy/mobile/presentation/home/recent_folder/mobile_recent_vi
import 'package:appflowy/workspace/application/recent/prelude.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/protobuf.dart';
import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra_ui/style_widget/text.dart';
-import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -62,37 +61,35 @@ class _RecentViews extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return SizedBox(
- height: 168,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: FlowyText.semibold(
- LocaleKeys.sideBar_recent.tr(),
- fontSize: 20.0,
- ),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: FlowyText.semibold(
+ LocaleKeys.sideBar_recent.tr(),
+ fontSize: 20.0,
),
- Expanded(
- child: ListView.separated(
- separatorBuilder: (context, index) => const HSpace(8),
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 8,
- ),
- scrollDirection: Axis.horizontal,
- itemCount: recentViews.length,
- itemBuilder: (context, index) {
- return MobileRecentView(
- view: recentViews[index],
- height: 120,
- );
- },
+ ),
+ SingleChildScrollView(
+ scrollDirection: Axis.horizontal,
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+ child: IntrinsicHeight(
+ child: SeparatedRow(
+ separatorBuilder: () => const HSpace(8),
+ children: recentViews
+ .map(
+ (view) => SizedBox(
+ width: 150,
+ child: MobileRecentView(view: view),
+ ),
+ )
+ .toList(),
),
),
- ],
- ),
+ ),
+ ],
);
}
}
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_recent_view.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_recent_view.dart
index 4d04e08acd..01d5dee7ce 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_recent_view.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/recent_folder/mobile_recent_view.dart
@@ -12,7 +12,7 @@ import 'package:appflowy_backend/protobuf/flowy-document2/protobuf.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:cached_network_image/cached_network_image.dart';
-import 'package:flowy_infra_ui/style_widget/text.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:string_validator/string_validator.dart';
@@ -20,11 +20,9 @@ class MobileRecentView extends StatefulWidget {
const MobileRecentView({
super.key,
required this.view,
- required this.height,
});
final ViewPB view;
- final double height;
@override
State<MobileRecentView> createState() => _MobileRecentViewState();
@@ -76,71 +74,55 @@ class _MobileRecentViewState extends State<MobileRecentView> {
return GestureDetector(
onTap: () => context.pushView(view),
- child: Container(
- height: widget.height,
- width: widget.height,
- decoration: BoxDecoration(
- color: theme.colorScheme.background,
- borderRadius: BorderRadius.circular(8),
- border: Border.all(
- color: theme.colorScheme.outline,
- ),
- ),
- child: Stack(
- children: [
- Positioned(
- top: 0,
- left: 0,
- right: 0,
- child: SizedBox(
- height: widget.height / 2.0,
- width: double.infinity,
- child: ClipRRect(
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(8),
- topRight: Radius.circular(8),
- ),
- child: _buildCoverWidget(),
- ),
- ),
+ child: Stack(
+ children: [
+ Container(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(8),
+ border: Border.all(color: theme.colorScheme.outline),
),
- Align(
- alignment: Alignment.centerLeft,
- child: Padding(
- padding: const EdgeInsets.only(left: 4),
- child: icon.isNotEmpty
- ? EmojiText(
- emoji: icon,
- fontSize: 30.0,
- )
- : SizedBox.square(
- dimension: 32.0,
- child: view.defaultIcon(),
- ),
- ),
- ),
- Positioned(
- bottom: 0,
- left: 0,
- right: 0,
- child: Container(
- height: widget.height / 2.0,
- width: double.infinity,
- padding: const EdgeInsets.only(
- left: 8.0,
- top: 14.0,
- right: 8.0,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(
+ child: ClipRRect(
+ borderRadius: const BorderRadius.only(
+ topLeft: Radius.circular(8),
+ topRight: Radius.circular(8),
+ ),
+ child: _buildCoverWidget(),
+ ),
),
- child: FlowyText(
- view.name,
- maxLines: 2,
- fontSize: 14.0,
- overflow: TextOverflow.ellipsis,
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(8, 16, 8, 2),
+ child: FlowyText(
+ view.name,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
),
- ),
+ ],
+ ),
+ ),
+ Align(
+ alignment: Alignment.centerLeft,
+ child: Padding(
+ padding: const EdgeInsets.only(left: 4),
+ child: icon.isNotEmpty
+ ? EmojiText(
+ emoji: icon,
+ fontSize: 30.0,
+ )
+ : SizedBox.square(
+ dimension: 32.0,
+ child: view.defaultIcon(),
+ ),
),
- ],
- ),
+ ),
+ ],
),
);
}
diff --git a/frontend/appflowy_flutter/lib/startup/deps_resolver.dart b/frontend/appflowy_flutter/lib/startup/deps_resolver.dart
index af3e06a6fb..7f72902be9 100644
--- a/frontend/appflowy_flutter/lib/startup/deps_resolver.dart
+++ b/frontend/appflowy_flutter/lib/startup/deps_resolver.dart
@@ -29,7 +29,6 @@ import 'package:appflowy/workspace/application/user/prelude.dart';
import 'package:appflowy/workspace/application/view/prelude.dart';
import 'package:appflowy/workspace/application/workspace/prelude.dart';
import 'package:appflowy/workspace/presentation/home/menu/menu_shared_state.dart';
-import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-folder2/view.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
import 'package:flowy_infra/file_picker/file_picker_impl.dart';