revanced-manager/lib/ui/views/patcher/patcher_view.dart
2022-09-01 01:25:19 +01:00

128 lines
5.5 KiB
Dart

import 'package:animations/animations.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/theme.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
import 'package:revanced_manager/ui/views/installer/installer_view.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view.dart';
import 'package:revanced_manager/ui/widgets/patcherView/app_selector_card.dart';
import 'package:revanced_manager/ui/widgets/patcherView/patch_selector_card.dart';
import 'package:stacked/stacked.dart';
class PatcherView extends StatelessWidget {
const PatcherView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ViewModelBuilder<PatcherViewModel>.reactive(
disposeViewModel: false,
viewModelBuilder: () => locator<PatcherViewModel>(),
builder: (context, model, child) => Scaffold(
floatingActionButton: Visibility(
visible: model.showPatchButton(),
child: OpenContainer(
transitionDuration: const Duration(milliseconds: 400),
openBuilder: (_, openContainer) => const InstallerView(),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
closedBuilder: (_, openContainer) => FloatingActionButton.extended(
label: I18nText('patcherView.patchButton'),
icon: const Icon(Icons.build),
onPressed: openContainer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
backgroundColor: Theme.of(context).colorScheme.secondary,
foregroundColor: Theme.of(context).colorScheme.surface,
),
),
),
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(
'patcherView.widgetTitle',
child: Text(
'',
style: GoogleFonts.inter(
color: Theme.of(context).textTheme.headline5!.color,
fontWeight: FontWeight.w500,
),
),
),
),
),
SliverPadding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
OpenContainer(
transitionDuration: const Duration(milliseconds: 400),
openBuilder: (_, openContainer) =>
const AppSelectorView(),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
closedBuilder: (_, openContainer) => AppSelectorCard(
onPressed: openContainer,
color: Theme.of(context).colorScheme.primary,
),
),
const SizedBox(height: 16),
Opacity(
opacity: isDark
? (model.dimPatchesCard() ? 0.5 : 1)
: (model.dimPatchesCard() ? 0.75 : 1),
child: OpenContainer(
transitionDuration: const Duration(milliseconds: 400),
openBuilder: (_, openContainer) =>
const PatchesSelectorView(),
openColor: Theme.of(context).colorScheme.primary,
closedColor: Colors.transparent,
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
closedBuilder: (_, openContainer) => PatchSelectorCard(
onPressed:
model.dimPatchesCard() ? () => {} : openContainer,
color: Theme.of(context).colorScheme.primary,
),
),
),
],
),
),
),
],
),
),
);
}
}