mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Flutter 3.29 beta (#2571)
This commit is contained in:
@@ -5,8 +5,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Simple Localizations similar to
|
||||
/// https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization#an-alternative-class-for-the-apps-localized-resources
|
||||
class AppLocalization {
|
||||
static AppLocalization of(BuildContext context) {
|
||||
return Localizations.of(context, AppLocalization);
|
||||
|
||||
@@ -10,8 +10,9 @@ abstract final class AppColors {
|
||||
static const grey1 = Color(0xFFF2F2F2);
|
||||
static const grey2 = Color(0xFF4D4D4D);
|
||||
static const grey3 = Color(0xFFA4A4A4);
|
||||
static const whiteTransparent =
|
||||
Color(0x4DFFFFFF); // Figma rgba(255, 255, 255, 0.3)
|
||||
static const whiteTransparent = Color(
|
||||
0x4DFFFFFF,
|
||||
); // Figma rgba(255, 255, 255, 0.3)
|
||||
static const blackTransparent = Color(0x4D000000);
|
||||
static const red1 = Color(0xFFE74C3C);
|
||||
|
||||
|
||||
@@ -27,17 +27,20 @@ abstract final class Dimens {
|
||||
|
||||
/// Symmetric padding for screen edges
|
||||
EdgeInsets get edgeInsetsScreenSymmetric => EdgeInsets.symmetric(
|
||||
horizontal: paddingScreenHorizontal, vertical: paddingScreenVertical);
|
||||
horizontal: paddingScreenHorizontal,
|
||||
vertical: paddingScreenVertical,
|
||||
);
|
||||
|
||||
static const Dimens desktop = _DimensDesktop();
|
||||
static const Dimens mobile = _DimensMobile();
|
||||
|
||||
/// Get dimensions definition based on screen size
|
||||
factory Dimens.of(BuildContext context) =>
|
||||
switch (MediaQuery.sizeOf(context).width) {
|
||||
> 600 => desktop,
|
||||
_ => mobile,
|
||||
};
|
||||
factory Dimens.of(BuildContext context) => switch (MediaQuery.sizeOf(
|
||||
context,
|
||||
).width) {
|
||||
> 600 && < 840 => desktop,
|
||||
_ => mobile,
|
||||
};
|
||||
}
|
||||
|
||||
/// Mobile dimensions
|
||||
|
||||
@@ -9,26 +9,11 @@ import 'colors.dart';
|
||||
|
||||
abstract final class AppTheme {
|
||||
static const _textTheme = TextTheme(
|
||||
headlineLarge: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
headlineSmall: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
titleMedium: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
bodyLarge: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
bodyMedium: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
headlineLarge: TextStyle(fontSize: 32, fontWeight: FontWeight.w500),
|
||||
headlineSmall: TextStyle(fontSize: 18, fontWeight: FontWeight.w400),
|
||||
titleMedium: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
bodyLarge: TextStyle(fontSize: 18, fontWeight: FontWeight.w400),
|
||||
bodyMedium: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
|
||||
bodySmall: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
|
||||
@@ -10,11 +10,7 @@ import 'blur_filter.dart';
|
||||
|
||||
/// Custom back button to pop navigation.
|
||||
class CustomBackButton extends StatelessWidget {
|
||||
const CustomBackButton({
|
||||
super.key,
|
||||
this.onTap,
|
||||
this.blur = false,
|
||||
});
|
||||
const CustomBackButton({super.key, this.onTap, this.blur = false});
|
||||
|
||||
final bool blur;
|
||||
final GestureTapCallback? onTap;
|
||||
|
||||
@@ -28,9 +28,10 @@ class CustomCheckbox extends StatelessWidget {
|
||||
),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
color: value
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent,
|
||||
color:
|
||||
value
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent,
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
|
||||
@@ -46,9 +46,7 @@ class ErrorIndicator extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
FilledButton(
|
||||
onPressed: onPressed,
|
||||
style: const ButtonStyle(
|
||||
|
||||
@@ -11,10 +11,7 @@ import 'blur_filter.dart';
|
||||
|
||||
/// Home button to navigate back to the '/' path.
|
||||
class HomeButton extends StatelessWidget {
|
||||
const HomeButton({
|
||||
super.key,
|
||||
this.blur = false,
|
||||
});
|
||||
const HomeButton({super.key, this.blur = false});
|
||||
|
||||
final bool blur;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import 'package:flutter/material.dart';
|
||||
class AppCustomScrollBehavior extends MaterialScrollBehavior {
|
||||
@override
|
||||
Set<PointerDeviceKind> get dragDevices => {
|
||||
PointerDeviceKind.touch,
|
||||
// Allow to drag with mouse on Regions carousel
|
||||
PointerDeviceKind.mouse,
|
||||
};
|
||||
PointerDeviceKind.touch,
|
||||
// Allow to drag with mouse on Regions carousel
|
||||
PointerDeviceKind.mouse,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,11 +16,7 @@ import 'home_button.dart';
|
||||
/// Displays a search bar with the current configuration.
|
||||
/// Includes [HomeButton] to navigate back to the '/' path.
|
||||
class AppSearchBar extends StatelessWidget {
|
||||
const AppSearchBar({
|
||||
super.key,
|
||||
this.config,
|
||||
this.onTap,
|
||||
});
|
||||
const AppSearchBar({super.key, this.config, this.onTap});
|
||||
|
||||
final ItineraryConfig? config;
|
||||
final GestureTapCallback? onTap;
|
||||
@@ -59,9 +55,7 @@ class AppSearchBar extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _QueryText extends StatelessWidget {
|
||||
const _QueryText({
|
||||
required this.config,
|
||||
});
|
||||
const _QueryText({required this.config});
|
||||
|
||||
final ItineraryConfig? config;
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ class TagChip extends StatelessWidget {
|
||||
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: chipColor ??
|
||||
color:
|
||||
chipColor ??
|
||||
Theme.of(context).extension<TagChipTheme>()?.chipColor ??
|
||||
AppColors.whiteTransparent,
|
||||
),
|
||||
@@ -48,10 +49,11 @@ class TagChip extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
_iconFrom(tag),
|
||||
color: onChipColor ??
|
||||
Theme.of(context)
|
||||
.extension<TagChipTheme>()
|
||||
?.onChipColor ??
|
||||
color:
|
||||
onChipColor ??
|
||||
Theme.of(
|
||||
context,
|
||||
).extension<TagChipTheme>()?.onChipColor ??
|
||||
Colors.white,
|
||||
size: fontSize,
|
||||
),
|
||||
@@ -98,25 +100,23 @@ class TagChip extends StatelessWidget {
|
||||
// Note: original Figma file uses Google Sans
|
||||
// which is not available on GoogleFonts
|
||||
TextStyle _textStyle(BuildContext context) => GoogleFonts.openSans(
|
||||
textStyle: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: fontSize,
|
||||
color: onChipColor ??
|
||||
Theme.of(context).extension<TagChipTheme>()?.onChipColor ??
|
||||
Colors.white,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
),
|
||||
);
|
||||
textStyle: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: fontSize,
|
||||
color:
|
||||
onChipColor ??
|
||||
Theme.of(context).extension<TagChipTheme>()?.onChipColor ??
|
||||
Colors.white,
|
||||
textBaseline: TextBaseline.alphabetic,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class TagChipTheme extends ThemeExtension<TagChipTheme> {
|
||||
final Color chipColor;
|
||||
final Color onChipColor;
|
||||
|
||||
TagChipTheme({
|
||||
required this.chipColor,
|
||||
required this.onChipColor,
|
||||
});
|
||||
TagChipTheme({required this.chipColor, required this.onChipColor});
|
||||
|
||||
@override
|
||||
ThemeExtension<TagChipTheme> copyWith({
|
||||
|
||||
Reference in New Issue
Block a user