Skip to content

Commit

Permalink
✨ settings screen
Browse files Browse the repository at this point in the history
  • Loading branch information
niuhuan committed Nov 22, 2023
1 parent 6c37764 commit 5580a04
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
18 changes: 18 additions & 0 deletions lib/basic/config/in_china.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:pansy/ffi.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

var _inChina = false;

Expand All @@ -13,3 +15,19 @@ Future initInChina() async {
await api.perInChina();
_inChina = await api.getInChina();
}

Widget inChinaSetting() {
return StatefulBuilder(
builder: (context, setState) {
return SwitchListTile(
title: Text(AppLocalizations.of(context)!.inChineseNetwork),
value: _inChina,
onChanged: (value) async {
await setInChina(value);
_inChina = value;
setState(() {});
},
);
},
);
}
5 changes: 4 additions & 1 deletion lib/screens/app_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:pansy/screens/downloads_screen.dart';
import 'package:pansy/screens/search_title_screen.dart';
import 'package:pansy/screens/discovery_screen.dart';
import 'package:pansy/screens/hots_screen.dart';
import 'package:pansy/screens/settings_screen.dart';
import 'package:pansy/states/pixiv_login.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Expand Down Expand Up @@ -201,7 +202,9 @@ class _AppScreenState extends State<AppScreen>
},
onSelected: (value) {
if (value == 1) {
// Navigator.pushNamed(context, '/settings');
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const SettingsScreen(),
));
} else if (value == 2) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const DownloadsScreen(),
Expand Down
18 changes: 18 additions & 0 deletions lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../basic/config/in_china.dart';

class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.settings),
),
body: ListView(children: [
inChinaSetting(),
]),
);
}
}

0 comments on commit 5580a04

Please sign in to comment.