Skip to content

Commit

Permalink
[Presentation] Minor fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Aug 19, 2023
1 parent 8f55e5c commit c613e24
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 67 deletions.
86 changes: 53 additions & 33 deletions lib/env.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import 'package:envied/envied.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_envify/flutter_envify.dart';

part 'env.g.dart';

class Env {
static const androidAppCenterKey = CommonEnv.androidAppCenterKey;
static const androidPurchasesKey = CommonEnv.androidPurchasesKey;
static const String androidAppCenterKey = CommonEnv.androidAppCenterKey;
static const String androidPurchasesKey = CommonEnv.androidPurchasesKey;

static const iosPurchasesKey = CommonEnv.iosPurchasesKey;
static const iosAppCenterKey = CommonEnv.iosAppCenterKey;
static const String iosPurchasesKey = CommonEnv.iosPurchasesKey;
static const String iosAppCenterKey = CommonEnv.iosAppCenterKey;

static const macosAppCenterKey = CommonEnv.macosAppCenterKey;
static const String macosAppCenterKey = CommonEnv.macosAppCenterKey;

static const commonHeaderName = CommonEnv.commonHeaderName;
static const apiHeaderName = CommonEnv.apiHeaderName;
static const String commonHeaderName = CommonEnv.commonHeaderName;
static const String apiHeaderName = CommonEnv.apiHeaderName;

static const publicKey = CommonEnv.publicKey;
static const privateKey = CommonEnv.privateKey;
static const letsEncryptKey = CommonEnv.letsEncryptKey;
static const String publicKey = CommonEnv.publicKey;
static const String privateKey = CommonEnv.privateKey;
static const String letsEncryptKey = CommonEnv.letsEncryptKey;

static const bool isReleaseMode = kReleaseMode;

Expand All @@ -28,33 +28,53 @@ class Env {
static const String apiHeaderValue = isReleaseMode ? ProdEnv.apiHeaderValue : DevEnv.apiHeaderValue;
}

@Envify(path: '.env.dev')
@Envied(path: '.env.dev', name: 'DevEnv')
abstract class DevEnv {
static const apiBaseUrl = _DevEnv.apiBaseUrl;
static const assetsBaseUrl = _DevEnv.assetsBaseUrl;
static const apiHeaderValue = _DevEnv.apiHeaderValue;
}
@EnviedField(varName: 'API_BASE_URL')
static const String apiBaseUrl = _DevEnv.apiBaseUrl;

@Envify(path: '.env.prod')
abstract class ProdEnv {
static const apiBaseUrl = _ProdEnv.apiBaseUrl;
static const assetsBaseUrl = _ProdEnv.assetsBaseUrl;
static const apiHeaderValue = _ProdEnv.apiHeaderValue;
@EnviedField(varName: 'ASSETS_BASE_URL')
static const String assetsBaseUrl = _DevEnv.assetsBaseUrl;

@EnviedField(varName: 'API_HEADER_VALUE')
static const String apiHeaderValue = _DevEnv.apiHeaderValue;
}

@Envify(path: '.env.common')
abstract class CommonEnv {
static const androidAppCenterKey = _CommonEnv.androidAppCenterKey;
static const iosAppCenterKey = _CommonEnv.iosAppCenterKey;
static const macosAppCenterKey = _CommonEnv.macosAppCenterKey;
@Envied(path: '.env.prod', name: 'ProdEnv')
abstract class ProdEnv {
@EnviedField(varName: 'API_BASE_URL')
static const String apiBaseUrl = _ProdEnv.apiBaseUrl;

static const androidPurchasesKey = _CommonEnv.androidPurchasesKey;
static const iosPurchasesKey = _CommonEnv.iosPurchasesKey;
@EnviedField(varName: 'ASSETS_BASE_URL')
static const String assetsBaseUrl = _ProdEnv.assetsBaseUrl;

static const commonHeaderName = _CommonEnv.commonHeaderName;
static const apiHeaderName = _CommonEnv.apiHeaderName;
@EnviedField(varName: 'API_HEADER_VALUE')
static const String apiHeaderValue = _ProdEnv.apiHeaderValue;
}

static const publicKey = _CommonEnv.publicKey;
static const privateKey = _CommonEnv.privateKey;
static const letsEncryptKey = _CommonEnv.letsEncryptKey;
@Envied(path: '.env.common', name: 'CommonEnv')
abstract class CommonEnv {
@EnviedField(varName: 'ANDROID_APP_CENTER_KEY')
static const String androidAppCenterKey = _CommonEnv.androidAppCenterKey;
@EnviedField(varName: 'IOS_APP_CENTER_KEY')
static const String iosAppCenterKey = _CommonEnv.iosAppCenterKey;
@EnviedField(varName: 'MACOS_APP_CENTER_KEY')
static const String macosAppCenterKey = _CommonEnv.macosAppCenterKey;

@EnviedField(varName: 'ANDROID_PURCHASES_KEY')
static const String androidPurchasesKey = _CommonEnv.androidPurchasesKey;
@EnviedField(varName: 'IOS_PURCHASES_KEY')
static const String iosPurchasesKey = _CommonEnv.iosPurchasesKey;

@EnviedField(varName: 'COMMON_HEADER_NAME')
static const String commonHeaderName = _CommonEnv.commonHeaderName;
@EnviedField(varName: 'API_HEADER_NAME')
static const String apiHeaderName = _CommonEnv.apiHeaderName;

@EnviedField(varName: 'PUBLIC_KEY')
static const String publicKey = _CommonEnv.publicKey;
@EnviedField(varName: 'PRIVATE_KEY')
static const String privateKey = _CommonEnv.privateKey;
@EnviedField(varName: 'LETS_ENCRYPT_KEY')
static const String letsEncryptKey = _CommonEnv.letsEncryptKey;
}
4 changes: 2 additions & 2 deletions lib/infrastructure/device_info_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class DeviceInfoServiceImpl implements DeviceInfoService {
Future<void> _initForIOs() async {
final deviceInfo = DeviceInfoPlugin();
final info = await deviceInfo.iosInfo;
final model = 'Model: ${info.model ?? na} --- Name: ${info.name ?? na}';
final osVersion = '${info.systemName ?? na} : ${info.systemVersion ?? na}';
final model = 'Model: ${info.model} --- Name: ${info.name}';
final osVersion = '${info.systemName} : ${info.systemVersion}';
_setDefaultDeviceInfoProps(model, osVersion);
_setOtherDeviceInfoProps(info.isPhysicalDevice);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/infrastructure/logging_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LoggingServiceImpl implements LoggingService {
void warning(Type type, String msg, [dynamic ex, StackTrace? trace]) {
assert(!msg.isNullEmptyOrWhitespace);
final tag = type.toString();
_logger.w('$tag - ${_formatEx(msg, ex)}', ex, trace);
_logger.w('$tag - ${_formatEx(msg, ex)}', error: ex, stackTrace: trace);

if (kReleaseMode) {
_trackWarningOrError(tag, msg, ex, trace);
Expand All @@ -55,7 +55,7 @@ class LoggingServiceImpl implements LoggingService {
void error(Type type, String msg, [dynamic ex, StackTrace? trace]) {
assert(!msg.isNullEmptyOrWhitespace);
final tag = type.toString();
_logger.e('$tag - ${_formatEx(msg, ex)}', ex, trace);
_logger.e('$tag - ${_formatEx(msg, ex)}', error: ex, stackTrace: trace);

if (kReleaseMode) {
_trackWarningOrError(tag, msg, ex, trace, true);
Expand Down
1 change: 0 additions & 1 deletion lib/presentation/characters/widgets/character_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class CharacterCard extends StatelessWidget {
shape: Styles.mainCardShape,
elevation: Styles.cardTenElevation,
color: elementType.getElementColorFromContext(context),
shadowColor: Colors.transparent,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
22 changes: 14 additions & 8 deletions lib/presentation/charts/charts_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:shiori/presentation/shared/extensions/i18n_extensions.dart';
import 'package:shiori/presentation/shared/loading.dart';
import 'package:shiori/presentation/shared/mixins/app_fab_mixin.dart';
import 'package:shiori/presentation/shared/nothing_found_column.dart';
import 'package:shiori/presentation/shared/shiori_icons.dart';
import 'package:shiori/presentation/shared/styles.dart';
import 'package:shiori/presentation/weapon/weapon_page.dart';

Expand Down Expand Up @@ -625,21 +626,26 @@ class _AscensionStats extends StatelessWidget {
maxNumberOfColumns: maxNumberOfColumns,
),
),
direction: Axis.vertical,
borderRadius: BorderRadius.circular(10),
constraints: const BoxConstraints(minHeight: 25, maxHeight: 25),
constraints: const BoxConstraints(minHeight: 36, maxHeight: 36),
isSelected: [
state.itemType == ItemType.character,
state.itemType == ItemType.weapon,
],
children: [
Container(
margin: Styles.edgeInsetHorizontal16,
child: Text(s.characters),
Tooltip(
message: s.characters,
child: Container(
margin: Styles.edgeInsetHorizontal16,
child: const Icon(Icons.people),
),
),
Container(
margin: Styles.edgeInsetHorizontal16,
child: Text(s.weapons),
Tooltip(
message: s.weapons,
child: Container(
margin: Styles.edgeInsetHorizontal16,
child: const Icon(Shiori.crossed_swords),
),
),
],
),
Expand Down
15 changes: 6 additions & 9 deletions lib/presentation/charts/widgets/horizontal_bar_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,18 @@ class HorizontalBarChart extends StatelessWidget {
maxX: maxX,
maxY: maxY,
lineTouchData: LineTouchData(
handleBuiltInTouches: true,
touchCallback: (event, response) {
if (event is FlTapUpEvent && response?.lineBarSpots != null && response!.lineBarSpots!.isNotEmpty) {
onPointTap?.call(response.lineBarSpots!.first.x);
}
},
touchTooltipData: LineTouchTooltipData(
tooltipBgColor: toolTipBgColor ?? theme.backgroundColor,
tooltipBgColor: toolTipBgColor ?? theme.colorScheme.background,
fitInsideHorizontally: true,
getTooltipItems: getTooltipItems,
getTooltipItems: getTooltipItems ?? defaultLineTooltipItem,
),
),
gridData: FlGridData(show: false),
gridData: const FlGridData(show: false),
titlesData: FlTitlesData(
bottomTitles: AxisTitles(
sideTitles: SideTitles(
Expand All @@ -94,8 +93,8 @@ class HorizontalBarChart extends StatelessWidget {
getTitlesWidget: (value, meta) => _BottomTitle(getBottomText: getBottomText, bottomTextMaxLength: bottomTextMaxLength, value: value),
),
),
rightTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
rightTitles: const AxisTitles(),
topTitles: const AxisTitles(),
leftTitles: AxisTitles(
sideTitles: SideTitles(
getTitlesWidget: (value, meta) => _LeftTitle(getLeftText: getLeftText, leftTextMaxLength: leftTextMaxLength, value: value),
Expand All @@ -109,12 +108,10 @@ class HorizontalBarChart extends StatelessWidget {
lineBarsData: items
.map(
(e) => LineChartBarData(
isCurved: false,
color: e.color,
barWidth: barWidth,
isStrokeCapRound: true,
dotData: FlDotData(show: true),
belowBarData: BarAreaData(show: false),
belowBarData: BarAreaData(),
spots: e.points.map((e) {
if (!canValueBeRendered(e.x)) {
return FlSpot.nullSpot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ extension AppThemeTypeExtensions on AppAccentColorType {
primary: color,
secondary: color,
primaryContainer: color,
primaryVariant: color,
secondaryVariant: color,
);
final dark = ThemeData.dark().copyWith(
primaryColor: color,
Expand Down Expand Up @@ -82,8 +80,6 @@ extension AppThemeTypeExtensions on AppAccentColorType {
primary: color,
secondary: color,
primaryContainer: color,
primaryVariant: color,
secondaryVariant: color,
),
);
default:
Expand Down
3 changes: 0 additions & 3 deletions lib/presentation/shared/gradient_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class GradientCard extends StatelessWidget {
final Widget? child;
final LinearGradient gradient;
final double? elevation;
final Color? shadowColor;

const GradientCard({
super.key,
Expand All @@ -20,7 +19,6 @@ class GradientCard extends StatelessWidget {
this.clipBehavior = Clip.none,
this.child,
this.elevation,
this.shadowColor,
this.semanticContainer = true,
});

Expand All @@ -32,7 +30,6 @@ class GradientCard extends StatelessWidget {
child: Material(
type: MaterialType.card,
color: Colors.transparent,
shadowColor: shadowColor ?? Colors.transparent,
elevation: elevation ?? 0,
shape: shape ?? const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))),
clipBehavior: clipBehavior,
Expand Down
6 changes: 3 additions & 3 deletions lib/presentation/splash/splash_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:shiori/injection.dart';
import 'package:shiori/presentation/shared/dialogs/confirm_dialog.dart';
import 'package:shiori/presentation/shared/extensions/app_theme_type_extensions.dart';
import 'package:shiori/presentation/shared/styles.dart';
import 'package:wakelock/wakelock.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

class SplashPage extends StatelessWidget {
final LanguageModel language;
Expand Down Expand Up @@ -111,12 +111,12 @@ class SplashPage extends StatelessWidget {
}

void _initMain(AppResourceUpdateResultType result, BuildContext context) {
Wakelock.disable();
WakelockPlus.disable();
context.read<MainBloc>().add(MainEvent.init(updateResultType: result));
}

void _applyUpdate(CheckForUpdatesResult result, BuildContext context) {
Wakelock.enable();
WakelockPlus.enable();
context.read<SplashBloc>().add(SplashEvent.applyUpdate(result: result));
}
}
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import purchases_flutter
import share_plus
import shared_preferences_foundation
import url_launcher_macos
import wakelock_macos
import wakelock_plus
import window_size

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
Expand All @@ -29,6 +29,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin"))
}

0 comments on commit c613e24

Please sign in to comment.