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:
@@ -20,10 +20,7 @@ import '../view_models/search_form_viewmodel.dart';
|
||||
/// Users can tap one item to select it.
|
||||
/// Tapping again the same item will deselect it.
|
||||
class SearchFormContinent extends StatelessWidget {
|
||||
const SearchFormContinent({
|
||||
super.key,
|
||||
required this.viewModel,
|
||||
});
|
||||
const SearchFormContinent({super.key, required this.viewModel});
|
||||
|
||||
final SearchFormViewModel viewModel;
|
||||
|
||||
@@ -35,9 +32,7 @@ class SearchFormContinent extends StatelessWidget {
|
||||
listenable: viewModel.load,
|
||||
builder: (context, child) {
|
||||
if (viewModel.load.running) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (viewModel.load.error) {
|
||||
return Center(
|
||||
@@ -110,9 +105,7 @@ class _CarouselItem extends StatelessWidget {
|
||||
// NOTE: Getting "invalid image data" error for some of the images
|
||||
// e.g. https://rstr.in/google/tripedia/jlbgFDrSUVE
|
||||
return const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.grey3,
|
||||
),
|
||||
decoration: BoxDecoration(color: AppColors.grey3),
|
||||
child: SizedBox(width: 140, height: 140),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -14,10 +14,7 @@ import '../view_models/search_form_viewmodel.dart';
|
||||
///
|
||||
/// Opens a date range picker dialog when tapped.
|
||||
class SearchFormDate extends StatelessWidget {
|
||||
const SearchFormDate({
|
||||
super.key,
|
||||
required this.viewModel,
|
||||
});
|
||||
const SearchFormDate({super.key, required this.viewModel});
|
||||
|
||||
final SearchFormViewModel viewModel;
|
||||
|
||||
@@ -71,7 +68,7 @@ class SearchFormDate extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -16,10 +16,7 @@ const String addGuestsKey = 'add-guests';
|
||||
/// Users can tap the Plus and Minus icons to increase or decrease
|
||||
/// the number of guests.
|
||||
class SearchFormGuests extends StatelessWidget {
|
||||
const SearchFormGuests({
|
||||
super.key,
|
||||
required this.viewModel,
|
||||
});
|
||||
const SearchFormGuests({super.key, required this.viewModel});
|
||||
|
||||
final SearchFormViewModel viewModel;
|
||||
|
||||
@@ -44,10 +41,7 @@ class SearchFormGuests extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'Who',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
Text('Who', style: Theme.of(context).textTheme.titleMedium),
|
||||
_QuantitySelector(viewModel),
|
||||
],
|
||||
),
|
||||
@@ -81,22 +75,21 @@ class _QuantitySelector extends StatelessWidget {
|
||||
),
|
||||
ListenableBuilder(
|
||||
listenable: viewModel,
|
||||
builder: (context, _) => Text(
|
||||
viewModel.guests.toString(),
|
||||
style: viewModel.guests == 0
|
||||
? Theme.of(context).inputDecorationTheme.hintStyle
|
||||
: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
builder:
|
||||
(context, _) => Text(
|
||||
viewModel.guests.toString(),
|
||||
style:
|
||||
viewModel.guests == 0
|
||||
? Theme.of(context).inputDecorationTheme.hintStyle
|
||||
: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
key: const ValueKey(addGuestsKey),
|
||||
onTap: () {
|
||||
viewModel.guests++;
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.add_circle_outline,
|
||||
color: AppColors.grey3,
|
||||
),
|
||||
child: const Icon(Icons.add_circle_outline, color: AppColors.grey3),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -21,10 +21,7 @@ import 'search_form_submit.dart';
|
||||
/// Tapping on the submit button opens the [ResultsScreen] screen
|
||||
/// passing the search options as query parameters.
|
||||
class SearchFormScreen extends StatelessWidget {
|
||||
const SearchFormScreen({
|
||||
super.key,
|
||||
required this.viewModel,
|
||||
});
|
||||
const SearchFormScreen({super.key, required this.viewModel});
|
||||
|
||||
final SearchFormViewModel viewModel;
|
||||
|
||||
|
||||
@@ -19,10 +19,7 @@ const String searchFormSubmitButtonKey = 'submit-button';
|
||||
/// When tapped, it navigates to the [ResultsScreen]
|
||||
/// passing the search options as query parameters.
|
||||
class SearchFormSubmit extends StatefulWidget {
|
||||
const SearchFormSubmit({
|
||||
super.key,
|
||||
required this.viewModel,
|
||||
});
|
||||
const SearchFormSubmit({super.key, required this.viewModel});
|
||||
|
||||
final SearchFormViewModel viewModel;
|
||||
|
||||
@@ -63,16 +60,15 @@ class _SearchFormSubmitState extends State<SearchFormSubmit> {
|
||||
listenable: widget.viewModel,
|
||||
child: SizedBox(
|
||||
height: 52,
|
||||
child: Center(
|
||||
child: Text(AppLocalization.of(context).search),
|
||||
),
|
||||
child: Center(child: Text(AppLocalization.of(context).search)),
|
||||
),
|
||||
builder: (context, child) {
|
||||
return FilledButton(
|
||||
key: const ValueKey(searchFormSubmitButtonKey),
|
||||
onPressed: widget.viewModel.valid
|
||||
? widget.viewModel.updateItineraryConfig.execute
|
||||
: null,
|
||||
onPressed:
|
||||
widget.viewModel.valid
|
||||
? widget.viewModel.updateItineraryConfig.execute
|
||||
: null,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
@@ -88,13 +84,15 @@ class _SearchFormSubmitState extends State<SearchFormSubmit> {
|
||||
|
||||
if (widget.viewModel.updateItineraryConfig.error) {
|
||||
widget.viewModel.updateItineraryConfig.clearResult();
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(AppLocalization.of(context).errorWhileSavingItinerary),
|
||||
action: SnackBarAction(
|
||||
label: AppLocalization.of(context).tryAgain,
|
||||
onPressed: widget.viewModel.updateItineraryConfig.execute,
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalization.of(context).errorWhileSavingItinerary),
|
||||
action: SnackBarAction(
|
||||
label: AppLocalization.of(context).tryAgain,
|
||||
onPressed: widget.viewModel.updateItineraryConfig.execute,
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user