Skip to content

Commit

Permalink
preserve state and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmohsin7 committed Nov 15, 2024
1 parent 6f63745 commit adb7df7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 30 additions & 10 deletions app/lib/pages/apps/explore_install_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:friend_private/backend/schema/app.dart';
import 'package:friend_private/pages/apps/providers/add_app_provider.dart';
import 'package:friend_private/pages/apps/widgets/app_section_card.dart';
import 'package:friend_private/pages/apps/widgets/filter_sheet.dart';
import 'package:friend_private/pages/apps/list_item.dart';
Expand All @@ -25,12 +26,15 @@ class ExploreInstallPage extends StatefulWidget {
State<ExploreInstallPage> createState() => _ExploreInstallPageState();
}

class _ExploreInstallPageState extends State<ExploreInstallPage> {
class _ExploreInstallPageState extends State<ExploreInstallPage> with AutomaticKeepAliveClientMixin {
late TextEditingController searchController;

@override
void initState() {
searchController = TextEditingController();
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<AddAppProvider>().init();
});
super.initState();
}

Expand All @@ -42,6 +46,7 @@ class _ExploreInstallPageState extends State<ExploreInstallPage> {

@override
Widget build(BuildContext context) {
super.build(context);
return Consumer<AppProvider>(builder: (context, provider, child) {
return CustomScrollView(
slivers: [
Expand Down Expand Up @@ -197,15 +202,27 @@ class _ExploreInstallPageState extends State<ExploreInstallPage> {
),
);
}
return SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return AppListItem(
app: provider.filteredApps[index],
index: index,
);
},
childCount: provider.filteredApps.length,
return SliverToBoxAdapter(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (ctx, idx) {
return AppListItem(
app: provider.filteredApps[idx],
index:
provider.apps.indexWhere((element) => element.id == provider.filteredApps[idx].id),
);
},
separatorBuilder: (ctx, idx) {
return const SizedBox(height: 8);
},
itemCount: provider.filteredApps.length,
),
const SizedBox(height: 64),
],
),
);
},
Expand Down Expand Up @@ -252,4 +269,7 @@ class _ExploreInstallPageState extends State<ExploreInstallPage> {
);
});
}

@override
bool get wantKeepAlive => true;
}
2 changes: 2 additions & 0 deletions app/lib/pages/apps/manage_create_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:friend_private/backend/schema/app.dart';
import 'package:friend_private/pages/apps/add_app.dart';
import 'package:friend_private/pages/apps/list_item.dart';
import 'package:friend_private/providers/app_provider.dart';
import 'package:friend_private/utils/analytics/mixpanel.dart';
import 'package:friend_private/utils/other/temp.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -91,6 +92,7 @@ class ManageCreatePage extends StatelessWidget {
const SizedBox(height: 16),
GestureDetector(
onTap: () {
MixpanelManager().pageOpened('Submit App');
routeToPage(context, const AddAppPage());
},
child: Container(
Expand Down

0 comments on commit adb7df7

Please sign in to comment.