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-12 11:42:43 +02:00
|
|
|
import 'package:revanced_manager/theme.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/dashboard_raw_chip.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/homeView/installed_apps_card.dart';
|
|
|
|
import 'package:revanced_manager/ui/widgets/homeView/latest_commit_card.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,
|
2022-08-17 19:44:27 +02:00
|
|
|
fireOnModelReadyOnce: true,
|
|
|
|
onModelReady: (model) => model.initialize(),
|
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-08-24 14:22:36 +02:00
|
|
|
body: CustomScrollView(
|
|
|
|
slivers: <Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
pinned: true,
|
|
|
|
snap: false,
|
|
|
|
floating: false,
|
|
|
|
expandedHeight: 100.0,
|
|
|
|
automaticallyImplyLeading: false,
|
|
|
|
backgroundColor: MaterialStateColor.resolveWith(
|
|
|
|
(states) => states.contains(MaterialState.scrolledUnder)
|
|
|
|
? isDark
|
|
|
|
? Theme.of(context).colorScheme.primary
|
|
|
|
: Theme.of(context).navigationBarTheme.backgroundColor!
|
|
|
|
: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
),
|
|
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
|
|
titlePadding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 23.0,
|
|
|
|
horizontal: 20.0,
|
|
|
|
),
|
|
|
|
title: I18nText(
|
|
|
|
'homeView.widgetTitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: GoogleFonts.inter(
|
|
|
|
color: Theme.of(context).textTheme.headline5!.color,
|
|
|
|
fontWeight: FontWeight.w500,
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SliverPadding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
|
|
sliver: SliverList(
|
|
|
|
delegate: SliverChildListDelegate.fixed(
|
|
|
|
<Widget>[
|
|
|
|
I18nText(
|
|
|
|
'homeView.updatesSubtitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: GoogleFonts.inter(
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: isDark
|
|
|
|
? const Color(0xffD1E1FA)
|
|
|
|
: const Color(0xff384E6E),
|
|
|
|
),
|
2022-08-07 01:37:12 +02:00
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
const SizedBox(height: 10),
|
|
|
|
LatestCommitCard(
|
|
|
|
onPressed: () => model.updateManager(context),
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
const SizedBox(height: 23),
|
|
|
|
I18nText(
|
|
|
|
'homeView.patchedSubtitle',
|
|
|
|
child: Text(
|
|
|
|
'',
|
|
|
|
style: GoogleFonts.inter(
|
|
|
|
fontSize: 20,
|
|
|
|
color: isDark
|
|
|
|
? const Color(0xffD1E1FA)
|
|
|
|
: const Color(0xff384E6E),
|
|
|
|
),
|
2022-08-16 15:06:56 +02:00
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
DashboardChip(
|
|
|
|
label: "homeView.updatesAvailable",
|
|
|
|
isSelected: model.showUpdatableApps,
|
|
|
|
onSelected: (value) {
|
|
|
|
model.toggleUpdatableApps(true);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox(width: 10),
|
|
|
|
DashboardChip(
|
|
|
|
label: "homeView.installed",
|
|
|
|
isSelected: !model.showUpdatableApps,
|
|
|
|
onSelected: (value) {
|
|
|
|
model.toggleUpdatableApps(false);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
model.showUpdatableApps
|
2022-08-29 16:01:51 +02:00
|
|
|
? const AvailableUpdatesCard()
|
|
|
|
: const InstalledAppsCard()
|
2022-08-24 14:22:36 +02:00
|
|
|
],
|
|
|
|
),
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
|
|
|
),
|
2022-08-24 14:22:36 +02:00
|
|
|
],
|
2022-08-06 14:13:28 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|