mirror of
https://github.com/asjqkkkk/flutter-todos.git
synced 2025-08-26 14:06:29 +08:00
准备开始添加国际化
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:todo_list/pages/main_page.dart';
|
import 'package:todo_list/pages/main_page.dart';
|
||||||
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
SystemChrome.setPreferredOrientations([
|
SystemChrome.setPreferredOrientations([
|
||||||
@ -16,6 +17,22 @@ class MyApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'ToDo List',
|
title: 'ToDo List',
|
||||||
|
localizationsDelegates: [
|
||||||
|
// ... app-specific localization delegate[s] here
|
||||||
|
GlobalMaterialLocalizations.delegate,
|
||||||
|
GlobalWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
supportedLocales: [
|
||||||
|
const Locale('en', 'US'), // 美国英语
|
||||||
|
const Locale('zh', 'CN'), // 中文简体
|
||||||
|
],
|
||||||
|
localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales){
|
||||||
|
},
|
||||||
|
localeListResolutionCallback: (List<Locale> locales, Iterable<Locale> supportedLocales){
|
||||||
|
debugPrint("locales:${locales} supportedLocales${supportedLocales} ");
|
||||||
|
|
||||||
|
},
|
||||||
|
locale: Locale('en', 'US'),
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primaryColor: Color.fromRGBO(246,200,200,1),
|
primaryColor: Color.fromRGBO(246,200,200,1),
|
||||||
primaryColorDark: Color.fromRGBO(255,180,180,1),
|
primaryColorDark: Color.fromRGBO(255,180,180,1),
|
||||||
|
@ -6,7 +6,7 @@ import 'package:todo_list/items/task_item.dart';
|
|||||||
import 'package:todo_list/utils/full_screen_dialog_util.dart';
|
import 'package:todo_list/utils/full_screen_dialog_util.dart';
|
||||||
import 'package:todo_list/widgets/floating_border.dart';
|
import 'package:todo_list/widgets/floating_border.dart';
|
||||||
import 'package:todo_list/widgets/bottom_show_widget.dart';
|
import 'package:todo_list/widgets/bottom_show_widget.dart';
|
||||||
import 'package:todo_list/widgets/scale_floating_button.dart';
|
import 'package:todo_list/widgets/animated_floating_button.dart';
|
||||||
import 'all_page.dart';
|
import 'all_page.dart';
|
||||||
|
|
||||||
class MainPage extends StatefulWidget {
|
class MainPage extends StatefulWidget {
|
||||||
@ -39,7 +39,7 @@ class _MainPageState extends State<MainPage> {
|
|||||||
),
|
),
|
||||||
floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling,
|
floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling,
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||||
floatingActionButton: ScaleFloatingButton(),
|
floatingActionButton: AnimatedFloatingButton(),
|
||||||
body: Container(
|
body: Container(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
@ -5,12 +5,12 @@ import 'package:todo_list/utils/full_screen_dialog_util.dart';
|
|||||||
import 'package:todo_list/widgets/bottom_show_widget.dart';
|
import 'package:todo_list/widgets/bottom_show_widget.dart';
|
||||||
import 'package:todo_list/widgets/floating_border.dart';
|
import 'package:todo_list/widgets/floating_border.dart';
|
||||||
|
|
||||||
class ScaleFloatingButton extends StatefulWidget {
|
class AnimatedFloatingButton extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_ScaleFloatingButtonState createState() => _ScaleFloatingButtonState();
|
_AnimatedFloatingButtonState createState() => _AnimatedFloatingButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ScaleFloatingButtonState extends State<ScaleFloatingButton>
|
class _AnimatedFloatingButtonState extends State<AnimatedFloatingButton>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
Animation _animation;
|
Animation _animation;
|
||||||
@ -19,7 +19,7 @@ class _ScaleFloatingButtonState extends State<ScaleFloatingButton>
|
|||||||
void initState() {
|
void initState() {
|
||||||
_controller =
|
_controller =
|
||||||
AnimationController(vsync: this, duration: Duration(milliseconds: 500));
|
AnimationController(vsync: this, duration: Duration(milliseconds: 500));
|
||||||
_animation = new Tween(begin: 1.0, end: 2.0)
|
_animation = new Tween(begin: 0.0, end: 1.0)
|
||||||
.animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
|
.animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
@ -35,12 +35,10 @@ class _ScaleFloatingButtonState extends State<ScaleFloatingButton>
|
|||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: _animation,
|
animation: _animation,
|
||||||
builder: (ctx, child) {
|
builder: (ctx, child) {
|
||||||
return Transform.rotate(
|
return Transform.translate(
|
||||||
angle: (1- _animation.value) * pi * 2,
|
offset: Offset(0, (_animation.value) * 56),
|
||||||
child: Transform.scale(
|
|
||||||
scale: _animation.value,
|
|
||||||
child: child,
|
child: child,
|
||||||
));
|
);
|
||||||
},
|
},
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
@ -19,6 +19,9 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
#国际化
|
||||||
|
flutter_localizations:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
@ -27,6 +30,8 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
#intl语言包
|
||||||
|
# intl_translation: ^0.17.5
|
||||||
|
|
||||||
|
|
||||||
#网络请求
|
#网络请求
|
||||||
@ -42,7 +47,9 @@ dev_dependencies:
|
|||||||
#滑动控件
|
#滑动控件
|
||||||
carousel_slider: ^1.3.0
|
carousel_slider: ^1.3.0
|
||||||
#环形列表
|
#环形列表
|
||||||
circle_list: ^0.0.6
|
circle_list: ^0.0.7
|
||||||
|
#intl语言包
|
||||||
|
# intl: ^0.15.8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user