mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-03 13:20:34 +00:00
Changed segmented buttons
This commit is contained in:
parent
a682609d8b
commit
9b4cb09dc2
4 changed files with 51 additions and 35 deletions
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:segmented_button_slide/segmented_button_slide.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
import 'package:adguard_home_manager/functions/open_url.dart';
|
||||
|
@ -124,25 +125,26 @@ class _AddCustomRuleState extends State<AddCustomRule> {
|
|||
),
|
||||
),
|
||||
Container(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: SegmentedButton(
|
||||
segments: [
|
||||
ButtonSegment(
|
||||
value: BlockingPresets.block,
|
||||
label: Text(AppLocalizations.of(context)!.block)
|
||||
),
|
||||
ButtonSegment(
|
||||
value: BlockingPresets.unblock,
|
||||
label: Text(AppLocalizations.of(context)!.unblock)
|
||||
),
|
||||
ButtonSegment(
|
||||
value: BlockingPresets.custom,
|
||||
label: Text(AppLocalizations.of(context)!.custom)
|
||||
),
|
||||
],
|
||||
selected: <BlockingPresets>{preset},
|
||||
onSelectionChanged: (value) => setState(() => preset = value.first),
|
||||
SegmentedButtonSlide(
|
||||
entries: [
|
||||
SegmentedButtonSlideEntry(label: AppLocalizations.of(context)!.block),
|
||||
SegmentedButtonSlideEntry(label: AppLocalizations.of(context)!.unblock),
|
||||
SegmentedButtonSlideEntry(label: AppLocalizations.of(context)!.custom),
|
||||
],
|
||||
selectedEntry: preset.index,
|
||||
onChange: (v) => setState(() => preset = BlockingPresets.values[v]),
|
||||
colors: SegmentedButtonSlideColors(
|
||||
barColor: Theme.of(context).colorScheme.primary.withOpacity(0.2),
|
||||
backgroundSelectedColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundSelectedColor: Theme.of(context).colorScheme.onPrimary,
|
||||
foregroundUnselectedColor: Theme.of(context).colorScheme.onSurface,
|
||||
hoverColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
fontSize: 14,
|
||||
height: 40,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
),
|
||||
),
|
||||
Container(height: 20),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:segmented_button_slide/segmented_button_slide.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
|
@ -371,21 +372,25 @@ class _AddServerModalState extends State<AddServerModal> {
|
|||
label: AppLocalizations.of(context)!.connection,
|
||||
padding: const EdgeInsets.all(24),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: SegmentedButton<ConnectionType>(
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: ConnectionType.http,
|
||||
label: Text("HTTP")
|
||||
),
|
||||
ButtonSegment(
|
||||
value: ConnectionType.https,
|
||||
label: Text("HTTPS")
|
||||
),
|
||||
],
|
||||
selected: <ConnectionType>{connectionType},
|
||||
onSelectionChanged: (value) => setState(() => connectionType = value.first),
|
||||
SegmentedButtonSlide(
|
||||
entries: const [
|
||||
SegmentedButtonSlideEntry(label: "HTTP"),
|
||||
SegmentedButtonSlideEntry(label: "HTTPS"),
|
||||
],
|
||||
selectedEntry: connectionType.index,
|
||||
onChange: (v) => setState(() => connectionType = ConnectionType.values[v]),
|
||||
colors: SegmentedButtonSlideColors(
|
||||
barColor: Theme.of(context).colorScheme.primary.withOpacity(0.2),
|
||||
backgroundSelectedColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundSelectedColor: Theme.of(context).colorScheme.onPrimary,
|
||||
foregroundUnselectedColor: Theme.of(context).colorScheme.onSurface,
|
||||
hoverColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
textOverflow: TextOverflow.ellipsis,
|
||||
fontSize: 14,
|
||||
height: 40,
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
|
10
pubspec.lock
10
pubspec.lock
|
@ -518,6 +518,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.5"
|
||||
segmented_button_slide:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: segmented_button_slide
|
||||
sha256: "96d67344fa65f6b98a317d930bfd4e81e47c4f9e3e2ab1ee8925b55f72cded13"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
sentry:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -789,5 +797,5 @@ packages:
|
|||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.1.0 <4.0.0"
|
||||
dart: ">=3.1.3 <4.0.0"
|
||||
flutter: ">=3.13.0"
|
||||
|
|
|
@ -75,6 +75,7 @@ dependencies:
|
|||
flutter_reorderable_list: ^1.3.1
|
||||
pie_chart: ^5.3.2
|
||||
flutter_hooks: ^0.20.3
|
||||
segmented_button_slide: ^1.0.4
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue