Skip to content

Commit

Permalink
app upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
toly1994328 committed Jan 1, 2025
1 parent 2958181 commit b753fc2
Show file tree
Hide file tree
Showing 26 changed files with 117 additions and 207 deletions.
12 changes: 7 additions & 5 deletions lib/src/navigation/view/mobile/unit_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:draw_system/draw_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_unit/src/navigation/model/app_tab.dart';

import 'package:treasure_tools/treasure_tools.dart';
import 'package:widget_module/blocs/blocs.dart';
import 'package:widget_module/widget_module.dart';

Expand Down Expand Up @@ -38,7 +38,9 @@ class _UnitPhoneNavigationState extends State<UnitPhoneNavigation> {
void initState() {
super.initState();
if (Platform.isAndroid || Platform.isIOS) {}
context.read<UpgradeBloc>().add(const CheckUpdate(appId: 1));
String locale =
context.read<AppConfigBloc>().state.language.locale.toString();
context.read<UpgradeBloc>().add(CheckUpdate(appId: 1, locale: locale));
}

@override
Expand All @@ -61,7 +63,7 @@ class _UnitPhoneNavigationState extends State<UnitPhoneNavigation> {
StandardHomePage(),
GalleryUnit(),
AlgoScope(child: ArtifactPage()),
CollectPageAdapter(),
MobileToolPage(),
UserPage(),
],
),
Expand All @@ -71,7 +73,6 @@ class _UnitPhoneNavigationState extends State<UnitPhoneNavigation> {

bool get isDark => Theme.of(context).brightness == Brightness.dark;


// 由于 bottomNavigationBar 颜色需要随 点击头部栏 状态而改变,
// 使用 BlocBuilder 构建
Widget _buildBottomNav(BuildContext context) {
Expand All @@ -80,7 +81,8 @@ class _UnitPhoneNavigationState extends State<UnitPhoneNavigation> {
ValueListenableBuilder(
valueListenable: _activeTab,
builder: (_, value, __) => PureBottomBar(
onTap: _onTapBottomNav, activeTab: value,
onTap: _onTapBottomNav,
activeTab: value,
)),
const Positioned(right: 22, top: 8, child: UpdateRedPoint())
],
Expand Down
2 changes: 1 addition & 1 deletion lib/src/starter/fx_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FxApplication with FxStarter<AppConfig> {

@override
void onStartSuccess(BuildContext context, AppConfig state) {
context.read<UpgradeBloc>().add(const CheckUpdate(appId: 1));
context.read<UpgradeBloc>().add(CheckUpdate(appId: 1,locale: state.language.locale.toString()));
context.go(AppRoute.widget.url);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/basic_system/app/lib/app/router/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum AppRoute {
codeStyle('code_style', url: '/setting/code_style'),
themeColor('theme_color', url: '/setting/theme_color'),
fontSetting('font_setting', url: '/setting/font_setting'),
version('version', url: '/setting/version'),
version('version', url: '/settings/version'),
;

final String path;
Expand Down
18 changes: 13 additions & 5 deletions modules/basic_system/app/lib/app/theme/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ ThemeData lightTheme(AppConfig state) {
statusBarIconBrightness: Brightness.dark,
);

String fontFamily = state.fontFamily;
if (kAppEnv.isWindows) {
fontFamily = '宋体';
}
return ThemeData(
fontFamily: '宋体',
fontFamily: fontFamily,
primaryColor: state.themeColor.color,
scaffoldBackgroundColor: const Color(0xffF3F4F6),
useMaterial3: true,
Expand Down Expand Up @@ -96,6 +100,9 @@ ThemeData lightTheme(AppConfig state) {
}),
tabBarTheme: TabBarTheme(
dividerColor: Colors.transparent,
// labelStyle: TextStyle(fontFamily: fontFamily),
// unselectedLabelStyle: TextStyle(fontFamily: fontFamily),

splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
Expand All @@ -112,10 +119,11 @@ ThemeData lightTheme(AppConfig state) {
elevation: 0,
centerTitle: true,
backgroundColor: Colors.white,
titleTextStyle: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black,
fontFamily: '宋体',

titleTextStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black,
fontFamily: fontFamily,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import 'package:app/app.dart';

class UnitUpgradeApi implements UpgradeApi {
@override
Future<ApiRet<AppInfo>> fetch(int appId) async {
Future<ApiRet<AppInfo>> fetch(int appId,String locale) async {
Host host = FxDio()<ScienceHost>();
String path = ScienceApi.appVersion.path;
return host.get<AppInfo>(
path,
queryParameters: {'app_id': 1, 'os': kAppEnv.os.name},
queryParameters: {
'app_id': 1,
'os': kAppEnv.os.name,
'locale': locale,
},
convertor: AppInfo.fromMap,
);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/basic_system/app/lib/http/science/science_host.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ScienceHost extends Host {

@override
Map<HostEnv, String> get value => {
HostEnv.release: 'api.toly1994.com',
HostEnv.release: 'toly1994.com',
HostEnv.dev: '192.168.109.244',
};

Expand All @@ -17,7 +17,7 @@ class ScienceHost extends Host {
);

@override
HostEnv get env => HostEnv.dev;
HostEnv get env => HostEnv.release;
}

enum ScienceApi {
Expand Down
12 changes: 10 additions & 2 deletions modules/basic_system/app_update/lib/bloc/bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ class UpgradeBloc extends Bloc<UpdateEvent, UpdateState> {
UpgradeBloc({required this.api}) : super(const NoUpdateState()) {
on<CheckUpdate>(_onCheckUpdate);
on<DownloadEvent>(_onDownloadEvent);
on<ProgressChangeEvent>(_onProgressChangeEvent);
}

void _onCheckUpdate(CheckUpdate event, Emitter<UpdateState> emit) async {
emit(const CheckLoadingState());
ApiRet<AppInfo> ret = await api.fetch(event.appId);
ApiRet<AppInfo> ret = await api.fetch(event.appId,event.locale);
if (ret.failed) {
emit(UpdateErrorState(error: ret.msg));
return;
Expand All @@ -46,8 +47,9 @@ class UpgradeBloc extends Bloc<UpdateEvent, UpdateState> {
if (curState is! ShouldUpdateState) return;

void onProgressChange(double progress) {
emit(curState.copyWith(progress: progress));
add(ProgressChangeEvent(progress: progress));
}

onProgressChange(0.001);

String url = event.appInfo.url;
Expand Down Expand Up @@ -86,4 +88,10 @@ class UpgradeBloc extends Bloc<UpdateEvent, UpdateState> {
callback(progress);
});
}

FutureOr<void> _onProgressChangeEvent(ProgressChangeEvent event, Emitter<UpdateState> emit) async{
UpdateState curState = state;
if (curState is! ShouldUpdateState) return;
emit(curState.copyWith(progress: event.progress));
}
}
12 changes: 11 additions & 1 deletion modules/basic_system/app_update/lib/bloc/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ sealed class UpdateEvent extends Equatable {
// 检查更新 ---> 校验,转换状态
class CheckUpdate extends UpdateEvent {
final int appId;
final String locale;

const CheckUpdate({required this.appId});
const CheckUpdate({required this.appId,required this.locale, });

@override
List<Object?> get props => [appId];
Expand All @@ -24,3 +25,12 @@ class DownloadEvent extends UpdateEvent {
@override
List<Object?> get props => [appInfo];
}

class ProgressChangeEvent extends UpdateEvent {
final double progress;

const ProgressChangeEvent({required this.progress});

@override
List<Object?> get props => [progress];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ typedef OnProgressChange = void Function(double progress);
abstract class UpgradeApi with CheckUpgrade {}

mixin CheckUpgrade {
Future<ApiRet<AppInfo>> fetch(int appId);
Future<ApiRet<AppInfo>> fetch(int appId,String locale);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:r_upgrade/r_upgrade.dart';
import 'package:utils/utils.dart';
import 'package:l10n/l10n.dart';

Expand Down Expand Up @@ -99,7 +96,8 @@ class AppUpdatePanel extends StatelessWidget {

void _tapByState(UpdateState state, BuildContext context) {
if (state is NoUpdateState) {
context.read<UpgradeBloc>().add(const CheckUpdate(appId: 1));
String locale = Localizations.localeOf(context).toString();
context.read<UpgradeBloc>().add( CheckUpdate(appId: 1,locale: locale));
}

if (state is ShouldUpdateState) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';

class NotSearchPage extends StatelessWidget {

const NotSearchPage({Key? key}):super(key: key);
final String tips;
const NotSearchPage({Key? key, required this.tips}):super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -18,7 +18,7 @@ class NotSearchPage extends StatelessWidget {
Container(
padding: const EdgeInsets.only(top: 16.0),
child: Text(
"哥们,搜点啥...≧◔◡◔≦",
tips,
style: TextStyle(
fontSize: 20,
color: color,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';

class ErrorPage extends StatelessWidget {

const ErrorPage({Key? key}):super(key: key);
Expand Down
2 changes: 2 additions & 0 deletions modules/basic_system/l10n/lib/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,7 @@
"my":"My",
"picture":"pics",
"widgetInn":"Widget Collection",
"emptySearch":"No Result \n(≡ _ ≡)/~┴┴",
"searchSomething":"Search Something ≧◔◡◔≦",
"slogan":"The unity of flutter, The unity of coder."
}
2 changes: 2 additions & 0 deletions modules/basic_system/l10n/lib/arb/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,7 @@
"my":"我的",
"picture":"幅",
"widgetInn":"组件酒肆",
"emptySearch":"没数据,哥也没办法\n(≡ _ ≡)/~┴┴",
"searchSomething":"哥们,搜点啥...≧◔◡◔≦",
"slogan":"Flutter 的联合,编程者的联合"
}
4 changes: 2 additions & 2 deletions modules/basic_system/l10n/lib/ext.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';

import 'gen_l10n/app_localizations.dart';

export 'gen_l10n/app_localizations.dart' show AppLocalizations;
const l10nDelegates = AppLocalizations.localizationsDelegates;
const l10nLocales = AppLocalizations.supportedLocales;

extension AppLocalizationsX on BuildContext {
AppLocalizations get l10n => AppLocalizations.of(this)!;
AppLocalizations get l10n => AppLocalizations.of(this);
}
12 changes: 12 additions & 0 deletions modules/basic_system/l10n/lib/gen_l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,18 @@ abstract class AppLocalizations {
/// **'组件酒肆'**
String get widgetInn;

/// No description provided for @emptySearch.
///
/// In zh, this message translates to:
/// **'没数据,哥也没办法\n(≡ _ ≡)/~┴┴'**
String get emptySearch;

/// No description provided for @searchSomething.
///
/// In zh, this message translates to:
/// **'哥们,搜点啥...≧◔◡◔≦'**
String get searchSomething;

/// No description provided for @slogan.
///
/// In zh, this message translates to:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get widgetInn => 'Widget Collection';

@override
String get emptySearch => 'No Result \n(≡ _ ≡)/~┴┴';

@override
String get searchSomething => 'Search Something ≧◔◡◔≦';

@override
String get slogan => 'The unity of flutter, The unity of coder.';
}
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get widgetInn => '组件酒肆';

@override
String get emptySearch => '没数据,哥也没办法\n(≡ _ ≡)/~┴┴';

@override
String get searchSomething => '哥们,搜点啥...≧◔◡◔≦';

@override
String get slogan => 'Flutter 的联合,编程者的联合';
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import 'package:flutter/material.dart';
import 'package:toly_ui/toly_ui.dart';

import 'package:l10n/l10n.dart';
import 'gallery_factory.dart';


Expand Down Expand Up @@ -72,7 +72,7 @@ class GalleryCardItem extends StatelessWidget {
padding:
const EdgeInsets.only(left: 6, right: 6, top: 2, bottom: 3),
child: Text(
"$count ",
"$count ${context.l10n.picture}",
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:l10n/l10n.dart';
class MobileToolPage extends StatelessWidget {
const MobileToolPage({super.key});

@override
Widget build(BuildContext context) {
AppLocalizations l10n = context.l10n;
String title = l10n.treasureTools;
String building = l10n.knowledgeConstruction;
return Scaffold(
appBar: AppBar(title: Text(title),),
body: Center(
child: Text(building),
),
);
}
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
library treasure_tools;

export 'src/code_gen_page.dart';
export 'src/view/mobile/mobile_tool_page.dart';
Loading

0 comments on commit b753fc2

Please sign in to comment.