123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:lszlgl/base/base_state.dart';
- import 'package:lszlgl/config/app_config.dart';
- import 'package:lszlgl/network/my_api.dart';
- import 'package:lszlgl/service/upgrade_service.dart';
- import 'package:lszlgl/widget/button.dart';
- import 'package:lszlgl/widget/card_item.dart';
- /// 设置
- class SettingPage extends StatefulWidget {
- const SettingPage({Key? key}) : super(key: key);
- @override
- State<SettingPage> createState() => _SettingPageState();
- }
- class _SettingPageState extends BaseState<SettingPage> {
- bool sound = true;
- bool shake = true;
- void onSave() {
- MyNavigator.showToast('保存成功');
- MyNavigator.pop();
- }
- void onVersionTap(bool show, {bool pop=false}) async {
- UpgradeService.checkUpgrade(show, pop: pop);
- }
- @override
- void initState() {
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return myScaffold(child: buildBody());
- }
- Widget buildBody() {
- return Column(
- children: [
- myAppBar(title: '设置'),
- buildList(),
- const SizedBox(height: 40),
- MyButton(
- '保 存',
- radius: 10,
- onTap: onSave,
- gradient: const LinearGradient(colors: [Color(0xFF3BD2E5), Color(0xFF247AF8)]),
- alignment: Alignment.center,
- minHeight: 40,
- margin: const EdgeInsets.symmetric(horizontal: 12),
- ),
- if(AppConfig.env == AppEnvironment.develop)
- Padding(
- padding: const EdgeInsets.only(top: 38.0),
- child: Text(MyApi.testUrl,style: const TextStyle(color: Color(0xFFA4A4A4),fontSize: 12),),
- )
- ],
- );
- }
- Widget buildList() {
- return Container(
- margin: const EdgeInsets.symmetric(horizontal: 12),
- clipBehavior: Clip.hardEdge,
- decoration: const BoxDecoration(
- color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8))),
- child: Column(
- children: [
- buildTit(),
- CardItemWidget(
- '声音',
- rightChild: buildSwitch(sound, (value) => setState(() => sound = value)),
- bottomLine: true,
- ),
- CardItemWidget(
- '震动',
- rightChild: buildSwitch(shake, (value) => setState(() => shake = value)),
- bottomLine: true,
- ),
- CardItemWidget('版本信息',
- rightText: 'V${AppConfig.packageInfo.version}',
- onTap: (){
- onVersionTap(true,pop: false);
- },
- bottomLine: true,
- ),
- CardItemWidget('更新内容',
- rightChild: const Icon(Icons.keyboard_arrow_right,size: 24, color: Color(0xFF01B2C8)),
- onTap: (){
- onVersionTap(true,pop: true);
- },
- ),
- ],
- ),
- );
- }
- Widget buildSwitch(bool value, ValueChanged changed) {
- return SizedBox(
- height: 24,
- child: CupertinoSwitch(value: value, onChanged: changed),
- );
- }
- Widget buildTit() {
- return Padding(
- padding: const EdgeInsets.all(12.0),
- child: Stack(
- alignment: Alignment.bottomLeft,
- children: [
- Container(
- height: 10,
- width: 78,
- decoration: const BoxDecoration(
- gradient: LinearGradient(
- colors: [Color(0xCC2379F8), Colors.white],
- ),
- ),
- ),
- const SizedBox(
- width: double.infinity,
- child: Text(
- '消息设置',
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
- ),
- )
- ],
- ),
- );
- }
- }
|