2023-01-30 13:35:06 +01:00
|
|
|
import 'package:animations/animations.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-07 01:37:12 +02:00
|
|
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
2022-08-16 15:06:56 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.dart';
|
2022-08-09 01:01:06 +02:00
|
|
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
2022-08-21 12:47:44 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/homeView/available_updates_card.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/homeView/installed_apps_card.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/homeView/latest_commit_card.dart';
|
2022-09-02 15:35:25 +02:00
|
|
|
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
|
2022-08-06 14:13:28 +02:00
|
|
|
import 'package:stacked/stacked.dart';
|
|
|
|
|
|
|
|
class HomeView extends StatelessWidget {
|
|
|
|
const HomeView({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-08-16 15:06:56 +02:00
|
|
|
return ViewModelBuilder<HomeViewModel>.reactive(
|
|
|
|
disposeViewModel: false,
|
2023-01-30 13:35:06 +01:00
|
|
|
onViewModelReady: (model) => model.initialize(context),
|
2022-08-16 15:06:56 +02:00
|
|
|
viewModelBuilder: () => locator<HomeViewModel>(),
|
2022-08-06 14:13:28 +02:00
|
|
|
builder: (context, model, child) => Scaffold(
|
2022-09-11 03:01:06 +02:00
|
|
|
body: RefreshIndicator(
|
2022-09-12 01:35:41 +02:00
|
|
|
onRefresh: () => model.forceRefresh(context),
|
2022-09-11 03:01:06 +02:00
|
|
|
child: CustomScrollView(
|
|
|
|
slivers: <Widget>[
|
|
|
|
CustomSliverAppBar(
|
2022-09-19 17:24:31 +02:00
|
|
|
isMainView: true,
|
2022-09-11 03:01:06 +02:00
|
|
|
title: I18nText(
|
|
|
|
'homeView.widgetTitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: GoogleFonts.inter(
|
2023-02-19 04:16:49 +01:00
|
|
|
color: Theme.of(context).textTheme.titleLarge!.color,
|
2022-09-11 03:01:06 +02:00
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
SliverPadding(
|
2022-09-12 18:30:44 +02:00
|
|
|
padding: const EdgeInsets.all(20.0),
|
2022-09-11 03:01:06 +02:00
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate.fixed(
|
|
|
|
<Widget>[
|
|
|
|
I18nText(
|
|
|
|
'homeView.updatesSubtitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
2023-02-19 04:16:49 +01:00
|
|
|
style: Theme.of(context).textTheme.titleLarge,
|
2022-09-11 03:01:06 +02:00
|
|
|
),
|
2022-08-07 01:37:12 +02:00
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
LatestCommitCard(
|
|
|
|
onPressed: () =>
|
|
|
|
model.showUpdateConfirmationDialog(context),
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
const SizedBox(height: 23),
|
|
|
|
I18nText(
|
|
|
|
'homeView.patchedSubtitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
2023-02-19 04:16:49 +01:00
|
|
|
style: Theme.of(context).textTheme.titleLarge,
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
2023-03-14 15:53:42 +01:00
|
|
|
ActionChip(
|
|
|
|
avatar: const Icon(Icons.grid_view),
|
2022-10-19 23:15:48 +02:00
|
|
|
label: I18nText('homeView.installed'),
|
2023-03-14 15:53:42 +01:00
|
|
|
side: BorderSide(
|
|
|
|
color: model.showUpdatableApps
|
|
|
|
? Theme.of(context).colorScheme.outline
|
|
|
|
: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondaryContainer,
|
|
|
|
width: model.showUpdatableApps ? 1 : 1,
|
|
|
|
),
|
|
|
|
backgroundColor: model.showUpdatableApps
|
|
|
|
? Theme.of(context).colorScheme.background
|
|
|
|
: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondaryContainer,
|
|
|
|
onPressed: () {
|
2022-10-19 23:15:48 +02:00
|
|
|
model.toggleUpdatableApps(false);
|
2022-09-11 03:01:06 +02:00
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox(width: 10),
|
2023-03-14 15:53:42 +01:00
|
|
|
ActionChip(
|
|
|
|
avatar: const Icon(Icons.update),
|
2022-10-19 23:15:48 +02:00
|
|
|
label: I18nText('homeView.updatesAvailable'),
|
2023-03-14 15:53:42 +01:00
|
|
|
side: BorderSide(
|
|
|
|
color: !model.showUpdatableApps
|
|
|
|
? Theme.of(context).colorScheme.outline
|
|
|
|
: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondaryContainer,
|
|
|
|
width: !model.showUpdatableApps ? 1 : 1,
|
|
|
|
),
|
|
|
|
backgroundColor: !model.showUpdatableApps
|
|
|
|
? Theme.of(context).colorScheme.background
|
|
|
|
: Theme.of(context)
|
|
|
|
.colorScheme
|
|
|
|
.secondaryContainer,
|
|
|
|
onPressed: () {
|
2022-10-19 23:15:48 +02:00
|
|
|
model.toggleUpdatableApps(true);
|
2022-09-11 03:01:06 +02:00
|
|
|
},
|
2023-03-14 15:53:42 +01:00
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 14),
|
2022-09-18 17:49:18 +02:00
|
|
|
PageTransitionSwitcher(
|
|
|
|
transitionBuilder:
|
|
|
|
(child, primaryAnimation, secondaryAnimation) {
|
|
|
|
return FadeThroughTransition(
|
|
|
|
animation: primaryAnimation,
|
|
|
|
secondaryAnimation: secondaryAnimation,
|
|
|
|
fillColor: Colors.transparent,
|
|
|
|
child: child,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
layoutBuilder: (entries) {
|
|
|
|
return Stack(
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
children: entries,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: model.showUpdatableApps
|
|
|
|
? AvailableUpdatesCard()
|
|
|
|
: InstalledAppsCard(),
|
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
],
|
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
2022-09-11 03:01:06 +02:00
|
|
|
],
|
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|