Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions violet/assets/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "Lite mode",
"litemodedesc": "Disable animations and shadows to reduce battery and CPU usage."
}
6 changes: 4 additions & 2 deletions violet/assets/locale/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "Malpeza reĝimo",
"litemodedesc": "Malŝaltas animaciojn kaj ombrojn por redukti baterian kaj CPU-uzon."
}
6 changes: 4 additions & 2 deletions violet/assets/locale/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "Modalità leggera",
"litemodedesc": "Disattiva animazioni e ombre per ridurre il consumo di batteria e CPU."
}
6 changes: 4 additions & 2 deletions violet/assets/locale/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "時間切れを無視",
"cropbookmark": "切り取りブックマーク",
"cropbookmarkdesc": "切り取った画像集を閲覧!"
}
"cropbookmarkdesc": "切り取った画像集を閲覧!",
"litemode": "ライトモード",
"litemodedesc": "アニメーションと影を無効化してバッテリーとCPU負荷を抑えます。"
}
6 changes: 4 additions & 2 deletions violet/assets/locale/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "앱 종료하기",
"ignoretimeout": "타임아웃 끄기",
"cropbookmark": "크롭 북마크",
"cropbookmarkdesc": "북마크한 크롭 이미지들을 한 번에 살펴보세요!"
}
"cropbookmarkdesc": "북마크한 크롭 이미지들을 한 번에 살펴보세요!",
"litemode": "라이트 모드",
"litemodedesc": "애니메이션과 그림자를 꺼 배터리·CPU 사용을 줄입니다."
}
6 changes: 4 additions & 2 deletions violet/assets/locale/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "Modo leve",
"litemodedesc": "Desative animações e sombras para reduzir o consumo de bateria e CPU."
}
6 changes: 4 additions & 2 deletions violet/assets/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "精簡模式",
"litemodedesc": "停用動畫與陰影以降低電量與 CPU 使用。"
}
6 changes: 4 additions & 2 deletions violet/assets/locale/zh_Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "精简模式",
"litemodedesc": "关闭动画和阴影以减少电量和 CPU 的消耗。"
}
6 changes: 4 additions & 2 deletions violet/assets/locale/zh_Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,7 @@
"exitTheApp": "Exit the app",
"ignoretimeout": "Ignore Timeout",
"cropbookmark": "Crop Bookmark",
"cropbookmarkdesc": "Expore your crop images!"
}
"cropbookmarkdesc": "Expore your crop images!",
"litemode": "精簡模式",
"litemodedesc": "停用動畫與陰影以降低電量與 CPU 使用。"
}
109 changes: 78 additions & 31 deletions violet/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'package:violet/pages/database_download/database_download_page.dart';
import 'package:violet/pages/lock/lock_screen.dart';
import 'package:violet/pages/splash/splash_page.dart';
import 'package:violet/settings/settings.dart';
import 'package:violet/settings/lite_mode.dart';
import 'package:violet/src/rust/frb_generated.dart';
import 'package:violet/style/palette.dart';

Expand Down Expand Up @@ -113,46 +114,61 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return DynamicTheme(
defaultBrightness: Brightness.light,
data: (brightness) => ThemeData(
appBarTheme: AppBarTheme(
systemOverlayStyle: !Settings.themeWhat.value
? SystemUiOverlayStyle.dark
: SystemUiOverlayStyle.light),
useMaterial3: false,
brightness: brightness,
bottomSheetTheme:
BottomSheetThemeData(backgroundColor: Colors.black.withOpacity(0)),
scaffoldBackgroundColor:
data: (brightness) {
final bool lite = LiteMode.enabled;
final Color? scaffoldColor =
Settings.themeBlack.value && Settings.themeWhat.value
? Colors.black
: null,
dialogBackgroundColor:
Settings.themeBlack.value && Settings.themeWhat.value
? Palette.blackThemeBackground
: null,
cardColor: Settings.themeBlack.value && Settings.themeWhat.value
? Palette.blackThemeBackground
: null,
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: Settings.majorColor.value, brightness: brightness),
cupertinoOverrideTheme: CupertinoThemeData(
: null;

return ThemeData(
appBarTheme: AppBarTheme(
systemOverlayStyle: !Settings.themeWhat.value
? SystemUiOverlayStyle.dark
: SystemUiOverlayStyle.light,
backgroundColor: lite ? scaffoldColor ?? Colors.transparent : null,
elevation: lite ? 0 : null,
shadowColor: lite ? Colors.transparent : null,
),
useMaterial3: false,
brightness: brightness,
primaryColor: Settings.majorColor.value,
textTheme: const CupertinoTextThemeData(),
barBackgroundColor: Settings.themeWhat.value
? Settings.themeBlack.value
? const Color(0xFF181818)
: Colors.grey.shade800
bottomSheetTheme: BottomSheetThemeData(
backgroundColor: lite
? scaffoldColor ?? Colors.transparent
: Colors.black.withOpacity(0),
elevation: lite ? 0 : null,
),
scaffoldBackgroundColor: scaffoldColor,
dialogBackgroundColor:
Settings.themeBlack.value && Settings.themeWhat.value
? Palette.blackThemeBackground
: null,
cardColor: Settings.themeBlack.value && Settings.themeWhat.value
? Palette.blackThemeBackground
: null,
),
),
shadowColor: lite ? Colors.transparent : null,
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: Settings.majorColor.value, brightness: brightness),
cupertinoOverrideTheme: CupertinoThemeData(
brightness: brightness,
primaryColor: Settings.majorColor.value,
textTheme: const CupertinoTextThemeData(),
barBackgroundColor: Settings.themeWhat.value
? Settings.themeBlack.value
? const Color(0xFF181818)
: Colors.grey.shade800
: null,
),
);
},
themedWidgetBuilder: (context, theme) {
return myApp(theme);
},
);
}

Widget myApp(ThemeData theme) {
final bool lite = LiteMode.enabled;
const supportedLocales = <Locale>[
Locale('en', 'US'),
Locale('ko', 'KR'),
Expand Down Expand Up @@ -191,17 +207,34 @@ class MyApp extends StatelessWidget {
return GetMaterialApp(
navigatorKey: navigatorKey,
navigatorObservers: navigatorObservers,
theme: theme,
theme: theme.copyWith(
splashFactory: lite ? NoSplash.splashFactory : theme.splashFactory,
pageTransitionsTheme: lite
? const PageTransitionsTheme(
builders: {
TargetPlatform.android: _NoTransitionsBuilder(),
TargetPlatform.iOS: _NoTransitionsBuilder(),
TargetPlatform.macOS: _NoTransitionsBuilder(),
TargetPlatform.windows: _NoTransitionsBuilder(),
TargetPlatform.linux: _NoTransitionsBuilder(),
},
)
: theme.pageTransitionsTheme,
visualDensity: lite ? VisualDensity.compact : theme.visualDensity,
),
home: home,
supportedLocales: supportedLocales,
routes: routes,
localizationsDelegates: localizationsDelegates,
localeResolutionCallback: localeResolution,
scrollBehavior: CustomScrollBehavior(),
builder: (context, child) {
final Widget body = child ?? Container();
final Widget heroAwareBody =
LiteMode.enabled ? HeroMode(enabled: false, child: body) : body;
return EscapeKeyListener(
navigatorKey: navigatorKey,
child: child ?? Container(),
child: heroAwareBody,
);
},
);
Expand Down Expand Up @@ -346,3 +379,17 @@ class MouseBackRecognizer extends BaseTapGestureRecognizer {
required PointerUpEvent up,
}) {}
}

class _NoTransitionsBuilder extends PageTransitionsBuilder {
const _NoTransitionsBuilder();

@override
Widget buildTransitions<T>(
PageRoute<T> route,
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return child;
}
}
14 changes: 9 additions & 5 deletions violet/lib/pages/article_info/article_info_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import 'package:violet/pages/viewer/viewer_page_provider.dart';
import 'package:violet/script/script_manager.dart';
import 'package:violet/server/violet_v2.dart';
import 'package:violet/settings/settings.dart';
import 'package:violet/settings/lite_mode.dart';
import 'package:violet/style/palette.dart';
import 'package:violet/variables.dart';
import 'package:violet/widgets/article_item/article_list_item_widget.dart';
Expand All @@ -58,6 +59,7 @@ class ArticleInfoPage extends StatelessWidget {
final height = MediaQuery.of(context).size.height;
final data = Provider.of<ArticleInfo>(context);
final mediaQuery = MediaQuery.of(context);
final bool lite = LiteMode.enabled;

Variables.setArticleInfoHeight(
height - 36 - (mediaQuery.padding + mediaQuery.viewInsets).bottom);
Expand All @@ -66,7 +68,7 @@ class ArticleInfoPage extends StatelessWidget {
color: Palette.themeColorLightShallow,
padding: EdgeInsets.only(top: 0, bottom: Variables.bottomBarHeight),
child: Card(
elevation: 5,
elevation: lite ? 0 : 5,
color: Palette.themeColorLightShallow,
child: SizedBox(
width: width - 16,
Expand Down Expand Up @@ -105,8 +107,9 @@ class ArticleInfoPage extends StatelessWidget {
iconColor: Settings.themeWhat.value
? Colors.white
: Colors.grey,
animationDuration:
const Duration(milliseconds: 500)),
animationDuration: lite
? Duration.zero
: const Duration(milliseconds: 500)),
header: Padding(
padding: const EdgeInsets.fromLTRB(12, 12, 0, 0),
child: Text(Translations.instance!.trans('preview')),
Expand Down Expand Up @@ -135,8 +138,9 @@ class ArticleInfoPage extends StatelessWidget {
iconColor: Settings.themeWhat.value
? Colors.white
: Colors.grey,
animationDuration:
const Duration(milliseconds: 500)),
animationDuration: lite
? Duration.zero
: const Duration(milliseconds: 500)),
header: Padding(
padding: const EdgeInsets.fromLTRB(12, 12, 0, 0),
child: Text(
Expand Down
Loading
Loading