mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
refactor: split widgets folder by screen usage.
This commit is contained in:
115
lib/ui/widgets/shared/application_item.dart
Normal file
115
lib/ui/widgets/shared/application_item.dart
Normal file
@ -0,0 +1,115 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/patch_text_button.dart';
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:timeago/timeago.dart';
|
||||
|
||||
class ApplicationItem extends StatelessWidget {
|
||||
final Uint8List icon;
|
||||
final String name;
|
||||
final DateTime patchDate;
|
||||
final String changelog;
|
||||
final bool isUpdatableApp;
|
||||
final Function() onPressed;
|
||||
|
||||
const ApplicationItem({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.name,
|
||||
required this.patchDate,
|
||||
required this.changelog,
|
||||
required this.isUpdatableApp,
|
||||
required this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ExpandablePanel(
|
||||
theme: const ExpandableThemeData(
|
||||
hasIcon: false,
|
||||
animationDuration: Duration(milliseconds: 450),
|
||||
),
|
||||
header: Container(
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(16),
|
||||
),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 12.0),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 60,
|
||||
child: Image.memory(
|
||||
icon,
|
||||
height: 39,
|
||||
width: 39,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 250,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
style: GoogleFonts.roboto(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
format(patchDate, locale: 'en_short'),
|
||||
style: kRobotoTextStyle.copyWith(
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
isUpdatableApp
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: PatchTextButton(
|
||||
text: 'applicationItem.patchButton',
|
||||
onPressed: onPressed,
|
||||
borderColor: isDark
|
||||
? const Color(0xff4D5054)
|
||||
: const Color.fromRGBO(119, 146, 168, 1),
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
],
|
||||
),
|
||||
),
|
||||
collapsed: const Text(""),
|
||||
expanded: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
I18nText(
|
||||
'applicationItem.changelogLabel',
|
||||
child: Text(
|
||||
'',
|
||||
style: kRobotoTextStyle.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
changelog,
|
||||
style: kRobotoTextStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
50
lib/ui/widgets/shared/patch_text_button.dart
Normal file
50
lib/ui/widgets/shared/patch_text_button.dart
Normal file
@ -0,0 +1,50 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
|
||||
class PatchTextButton extends StatelessWidget {
|
||||
final String text;
|
||||
final Function() onPressed;
|
||||
final Color borderColor;
|
||||
final Color backgroundColor;
|
||||
const PatchTextButton({
|
||||
Key? key,
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
this.borderColor = const Color(0xff7792BA),
|
||||
this.backgroundColor = Colors.transparent,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: onPressed,
|
||||
style: Theme.of(context).textButtonTheme.style?.copyWith(
|
||||
backgroundColor: MaterialStateProperty.all<Color?>(backgroundColor),
|
||||
side: MaterialStateProperty.all<BorderSide>(
|
||||
BorderSide(
|
||||
color: borderColor,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 4,
|
||||
),
|
||||
)),
|
||||
child: I18nText(text,
|
||||
child: Text(
|
||||
'',
|
||||
style: kInterTextStyle.copyWith(
|
||||
color: backgroundColor == Colors.transparent
|
||||
? const Color.fromRGBO(119, 146, 186, 1)
|
||||
: isDark
|
||||
? Colors.black
|
||||
: Colors.white,
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
106
lib/ui/widgets/shared/search_bar.dart
Normal file
106
lib/ui/widgets/shared/search_bar.dart
Normal file
@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class SearchBar extends StatefulWidget {
|
||||
final String? hintText;
|
||||
final Color? fillColor;
|
||||
final bool showSelectIcon;
|
||||
final Function(bool)? onSelectAll;
|
||||
final Color? backgroundColor;
|
||||
final Color? hintTextColor;
|
||||
|
||||
const SearchBar({
|
||||
Key? key,
|
||||
required this.hintText,
|
||||
required this.fillColor,
|
||||
required this.onQueryChanged,
|
||||
this.onSelectAll,
|
||||
this.showSelectIcon = false,
|
||||
this.backgroundColor = const Color(0xff1B222B),
|
||||
this.hintTextColor = Colors.white,
|
||||
}) : super(key: key);
|
||||
|
||||
final Function(String) onQueryChanged;
|
||||
|
||||
@override
|
||||
State<SearchBar> createState() => _SearchBarState();
|
||||
}
|
||||
|
||||
class _SearchBarState extends State<SearchBar> {
|
||||
final TextEditingController _textController = TextEditingController();
|
||||
bool _toggleSelectAll = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: widget.backgroundColor,
|
||||
border: Border.all(
|
||||
color: widget.backgroundColor != null
|
||||
? widget.backgroundColor!
|
||||
: Colors.white,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
onChanged: widget.onQueryChanged,
|
||||
controller: _textController,
|
||||
decoration: InputDecoration(
|
||||
fillColor: widget.fillColor,
|
||||
filled: true,
|
||||
contentPadding: const EdgeInsets.all(12.0),
|
||||
hintText: widget.hintText,
|
||||
hintStyle: GoogleFonts.poppins(
|
||||
color: widget.hintTextColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
prefixIcon: const Icon(
|
||||
Icons.search,
|
||||
size: 24.0,
|
||||
),
|
||||
suffixIcon: _textController.text.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
iconSize: 24.0,
|
||||
onPressed: () {
|
||||
_textController.clear();
|
||||
widget.onQueryChanged('');
|
||||
},
|
||||
)
|
||||
: widget.showSelectIcon
|
||||
? IconButton(
|
||||
icon: _toggleSelectAll
|
||||
? const Icon(Icons.deselect)
|
||||
: const Icon(Icons.select_all),
|
||||
iconSize: 24.0,
|
||||
onPressed: widget.onSelectAll != null
|
||||
? () {
|
||||
setState(() {
|
||||
_toggleSelectAll = !_toggleSelectAll;
|
||||
});
|
||||
widget.onSelectAll!(_toggleSelectAll);
|
||||
}
|
||||
: () => {},
|
||||
)
|
||||
: null,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user