forked from wednesday-solutions/flutter_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
home_page.dart
50 lines (46 loc) · 1.79 KB
/
home_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_template/presentation/base/page/base_page.dart';
import 'package:flutter_template/presentation/base/widgets/theme/theme_picker/theme_picker.dart';
import 'package:flutter_template/presentation/destinations/weather/home/home_screen_intent.dart';
import 'package:flutter_template/presentation/destinations/weather/home/home_screen_state.dart';
import 'package:flutter_template/presentation/destinations/weather/home/home_view_model.dart';
import 'package:flutter_template/presentation/entity/screen/screen.dart';
import 'widgets/home_page_body/home_page_body.dart';
class HomePage extends ConsumerWidget {
final HomeScreen homeScreen;
const HomePage({
Key? key,
required this.homeScreen,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
return BasePage<HomeScreen, HomeScreenState, HomeViewModel>(
viewModelProvider: homeViewModelProvider,
screen: homeScreen,
appBarActions: () => [
IconButton(
onPressed: () {
String locale = context.locale.toString();
if (locale == "hi_IN") {
context.setLocale(const Locale("en", "US"));
} else {
context.setLocale(const Locale("hi", "IN"));
}
},
icon: const Icon(Icons.language),
),
IconButton(
onPressed: () {
final viewModel = ref.watch(homeViewModelProvider.notifier);
viewModel.onIntent(HomeScreenIntent.search());
},
icon: const Icon(Icons.search),
),
const ThemePicker(),
],
body: const HomePageBody(),
);
}
}