Skip to content

Commit

Permalink
[fix] 修复了图标闪烁bug 主题添加拖动标注
Browse files Browse the repository at this point in the history
  • Loading branch information
steven12138 committed Mar 15, 2024
1 parent fa7cb78 commit 7f1d57f
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 58 deletions.
4 changes: 4 additions & 0 deletions lib/auth/view/info/unbind_dialogs.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:we_pei_yang_flutter/auth/network/auth_service.dart';
import 'package:we_pei_yang_flutter/commons/channel/statistics/umeng_statistics.dart';
import 'package:we_pei_yang_flutter/commons/network/classes_service.dart';
import 'package:we_pei_yang_flutter/commons/preferences/common_prefs.dart';
import 'package:we_pei_yang_flutter/commons/themes/template/wpy_theme_data.dart';
import 'package:we_pei_yang_flutter/commons/util/router_manager.dart';
import 'package:we_pei_yang_flutter/commons/util/text_util.dart';
import 'package:we_pei_yang_flutter/commons/util/toast_provider.dart';
import 'package:we_pei_yang_flutter/generated/l10n.dart';
import 'package:we_pei_yang_flutter/gpa/model/gpa_notifier.dart';
import 'package:we_pei_yang_flutter/main.dart';
import 'package:we_pei_yang_flutter/schedule/model/course_provider.dart';
import 'package:we_pei_yang_flutter/schedule/model/exam_provider.dart';

Expand Down
12 changes: 11 additions & 1 deletion lib/auth/view/settings/theme_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,17 @@ class _ThemeSettingState extends State<ThemeSetting>
),
),
],
)
),
Positioned(
left: 0,
right: 0,
bottom: 0.001.sw,
child: Icon(
Icons.drag_handle,
color: Colors.black.withOpacity(0.3),
size: 35.w,
),
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/commons/themes/template/wpy_theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:we_pei_yang_flutter/commons/themes/scheme/orange_scheme.dart';
import 'package:we_pei_yang_flutter/commons/themes/scheme/purple_scheme.dart';

import '../scheme/haitang_scheme.dart';
import '../scheme/dark_scheme.dart';
import '../scheme/green_scheme.dart';
import '../scheme/haitang_scheme.dart';
import '../scheme/light_scheme.dart';
import '../scheme/red_scheme.dart';
import '../scheme/yellow_scheme.dart';
Expand Down
8 changes: 7 additions & 1 deletion lib/commons/widgets/colored_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ class ColoredIcon extends StatefulWidget {
class _ColoredIconState extends State<ColoredIcon> {
ui.Image? _image = null;

static final _cache = <String, ui.Image>{};

Future<void> loadImageFromAssets(String assetPath) async {
final ByteData data = await rootBundle.load(assetPath);
final List<int> bytes = data.buffer.asUint8List();
final ui.Codec codec =
await ui.instantiateImageCodec(Uint8List.fromList(bytes));
final ui.FrameInfo fi = await codec.getNextFrame();
setState(() => _image = fi.image);
_cache[assetPath] = fi.image;
}

@override
void initState() {
super.initState();
loadImageFromAssets(widget.path);
if (_cache.containsKey(widget.path)) {
_image = _cache[widget.path];
} else
loadImageFromAssets(widget.path);
}

@override
Expand Down
1 change: 1 addition & 0 deletions lib/feedback/view/components/post_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import 'package:we_pei_yang_flutter/main.dart';

import '../../../commons/themes/template/wpy_theme_data.dart';
import '../../../commons/themes/wpy_theme.dart';
import '../../../commons/widgets/w_button.dart';

class PostCardNormal extends StatefulWidget {
/// 标准 PostCard
Expand Down
1 change: 1 addition & 0 deletions lib/feedback/view/components/widget/activity_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:we_pei_yang_flutter/commons/util/toast_provider.dart';
import 'package:we_pei_yang_flutter/feedback/view/components/widget/round_taggings.dart';
import 'package:we_pei_yang_flutter/feedback/view/lake_home_page/lake_notifier.dart';
import 'package:we_pei_yang_flutter/home/view/web_views/festival_page.dart';
import 'package:we_pei_yang_flutter/main.dart';

class ActivityCard extends StatefulWidget {
final double width;
Expand Down
1 change: 1 addition & 0 deletions lib/feedback/view/lake_home_page/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:extended_tabs/extended_tabs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:we_pei_yang_flutter/commons/preferences/common_prefs.dart';
import 'package:we_pei_yang_flutter/commons/util/text_util.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/feedback/view/lake_home_page/normal_sub_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:dio/dio.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 64 additions & 52 deletions lib/home/view/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,70 +117,82 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
var homePage = SizedBox(
height: 70.h,
width: width,
child: IconButton(
splashRadius: 1,
icon: _currentIndex == 0
? ColoredIcon(
'assets/images/home.png',
width: 24.h,
color: WpyTheme.of(context).primary,
)
: ColoredIcon(
'assets/images/home_grey.png',
width: 24.h,
//color: WpyTheme.of(context).get(WpyColorKey.unSelectedIcon,)
),
color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor),
onPressed: () => _tabController.animateTo(0),
child: AnimatedSwitcher(
duration: Duration(milliseconds: 300),
child: IconButton(
key: ValueKey(_currentIndex == 0),
splashRadius: 1,
icon: _currentIndex == 0
? ColoredIcon(
'assets/images/home.png',
width: 24.h,
color: WpyTheme.of(context).primary,
)
: ColoredIcon(
'assets/images/home_grey.png',
width: 24.h,
//color: WpyTheme.of(context).get(WpyColorKey.unSelectedIcon,)
),
color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor),
onPressed: () => _tabController.animateTo(0),
),
),
);

var feedbackPage = SizedBox(
height: 70.h,
width: width,
child: IconButton(
splashRadius: 1,
icon: _currentIndex == 1
? ColoredIcon(
'assets/images/lake.png',
width: 29.h,
color: WpyTheme.of(context).primary,
)
: ColoredIcon(
'assets/images/lake_grey.png',
width: 29.h,
//color: WpyTheme.of(context).get(WpyColorKey.unSelectedIcon),
),
color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor),
onPressed: () {
if (_currentIndex == 1) {
feedbackKey.currentState?.listToTop();
// 获取剪切板微口令
context.read<LakeModel>().getClipboardWeKoContents(context);
} else
_tabController.animateTo(1);
},
child: AnimatedSwitcher(
duration: Duration(milliseconds: 300),
child: IconButton(
key: ValueKey(_currentIndex == 1),
splashRadius: 1,
icon: _currentIndex == 1
? ColoredIcon(
'assets/images/lake.png',
width: 29.h,
color: WpyTheme.of(context).primary,
)
: ColoredIcon(
'assets/images/lake_grey.png',
width: 29.h,
//color: WpyTheme.of(context).get(WpyColorKey.unSelectedIcon),
),
color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor),
onPressed: () {
if (_currentIndex == 1) {
feedbackKey.currentState?.listToTop();
// 获取剪切板微口令
context.read<LakeModel>().getClipboardWeKoContents(context);
} else
_tabController.animateTo(1);
},
),
),
);

var selfPage = SizedBox(
height: 70.h,
width: width,
child: IconButton(
splashRadius: 1,
icon: _currentIndex == 2
? ColoredIcon(
'assets/images/my.png',
width: 24.h,
color: WpyTheme.of(context).primary,
)
: ColoredIcon(
'assets/images/my_grey.png',
width: 24.h,
//color: WpyTheme.of(context).get(WpyColorKey.unSelectedIcon),
),
color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor),
onPressed: () => _tabController.animateTo(2),
child: AnimatedSwitcher(
duration: Duration(milliseconds: 300),
child: IconButton(
key: ValueKey(_currentIndex == 2),
splashRadius: 1,
icon: _currentIndex == 2
? ColoredIcon(
'assets/images/my.png',
width: 24.h,
color: WpyTheme.of(context).primary,
)
: ColoredIcon(
'assets/images/my_grey.png',
width: 24.h,
//color: WpyTheme.of(context).get(WpyColorKey.unSelectedIcon),
),
color: WpyTheme.of(context).get(WpyColorKey.primaryBackgroundColor),
onPressed: () => _tabController.animateTo(2),
),
),
);

Expand Down
5 changes: 4 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:flutter/foundation.dart'
Expand All @@ -11,10 +12,11 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:provider/provider.dart';
import 'package:we_pei_yang_flutter/commons/themes/template/wpy_theme_data.dart';
import 'package:we_pei_yang_flutter/commons/font/font_loader.dart';
import 'package:we_pei_yang_flutter/commons/widgets/colored_icon.dart';
import 'package:we_pei_yang_flutter/studyroom/model/studyroom_provider.dart';
import 'package:window_manager/window_manager.dart';
import 'package:we_pei_yang_flutter/commons/widgets/colored_icon.dart';

import 'auth/network/auth_service.dart';
import 'auth/network/message_service.dart';
Expand Down Expand Up @@ -46,6 +48,7 @@ import 'message/model/message_provider.dart';
import 'schedule/model/course_provider.dart';
import 'schedule/model/exam_provider.dart';
import 'schedule/schedule_providers.dart';
import 'studyroom/model/studyroom_provider.dart';
import 'urgent_report/report_server.dart';

/// 应用入口
Expand Down
1 change: 1 addition & 0 deletions lib/schedule/network/experiment_service.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:we_pei_yang_flutter/auth/network/auth_service.dart';
import 'package:we_pei_yang_flutter/commons/network/classes_service.dart';
import 'package:we_pei_yang_flutter/commons/network/wpy_dio.dart';
import 'package:we_pei_yang_flutter/schedule/model/course.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/schedule/page/course_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand All @@ -22,6 +21,7 @@ import 'package:we_pei_yang_flutter/schedule/view/course_detail_widget.dart';
import 'package:we_pei_yang_flutter/schedule/view/course_dialog.dart';
import 'package:we_pei_yang_flutter/schedule/view/week_select_widget.dart';

import 'dart:ui' as ui;
import '../../commons/themes/wpy_theme.dart';
import '../../commons/util/toast_provider.dart';
import '../../commons/widgets/w_button.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/schedule/view/wpy_course_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'package:we_pei_yang_flutter/schedule/model/course.dart';
import 'package:we_pei_yang_flutter/schedule/model/course_provider.dart';

import '../../commons/widgets/w_button.dart';
import "package:we_pei_yang_flutter/schedule/extension/logic_extension.dart"
show isBeforeTermStart;

class TodayCoursesWidget extends StatelessWidget {
@override
Expand Down

0 comments on commit 7f1d57f

Please sign in to comment.