Skip to content

Commit

Permalink
Fix: 修复android搜索框在暗色主题下的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Jul 17, 2021
1 parent 18f021d commit 09ad3c5
Show file tree
Hide file tree
Showing 20 changed files with 816 additions and 607 deletions.
1 change: 0 additions & 1 deletion lib/common/service/dns_service.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:fehviewer/common/global.dart';
import 'package:fehviewer/const/const.dart';
import 'package:fehviewer/models/index.dart';
import 'package:fehviewer/utils/dns_util.dart';
Expand Down
7 changes: 5 additions & 2 deletions lib/const/theme_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ThemeColors {
/// 深色灰黑
static CupertinoThemeData darkGrayTheme = CupertinoThemeData(
brightness: Brightness.dark,
scaffoldBackgroundColor: Color.fromARGB(255, 30, 30, 30),
scaffoldBackgroundColor: const Color.fromARGB(255, 30, 30, 30),
barBackgroundColor: navigationBarBackgroundGray,
textTheme: ehTextTheme,
);
Expand Down Expand Up @@ -240,9 +240,12 @@ class ThemeColors {

static const CupertinoDynamicColor navigationBarBackgroundGray =
CupertinoDynamicColor.withBrightness(
debugLabel: 'navigationBarBackground',
debugLabel: 'navigationBarBackgroundGray',
// color: Color.fromARGB(230, 35, 35, 35),
color: Color.fromARGB(222, 249, 249, 249),
darkColor: Color.fromARGB(230, 35, 35, 35),
// color: Color.fromARGB(222, 186, 27, 27),
// darkColor: Color.fromARGB(230, 21, 212, 75),
);

static const Map<String, Color> colorRatingMap = <String, Color>{
Expand Down
97 changes: 58 additions & 39 deletions lib/models/dns_config.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:flutter/foundation.dart';
import 'dns_cache.dart';

import 'dns_cache.dart';

@immutable
class DnsConfig {

const DnsConfig({
this.enableDoH,
this.enableCustomHosts,
Expand All @@ -19,49 +18,69 @@ class DnsConfig {
final List<DnsCache>? hosts;
final List<DnsCache>? dohCache;

factory DnsConfig.fromJson(Map<String,dynamic> json) => DnsConfig(
enableDoH: json['enableDoH'] != null ? json['enableDoH'] as bool : null,
enableCustomHosts: json['enableCustomHosts'] != null ? json['enableCustomHosts'] as bool : null,
enableDomainFronting: json['enableDomainFronting'] != null ? json['enableDomainFronting'] as bool : null,
hosts: json['hosts'] != null ? (json['hosts'] as List? ?? []).map((e) => DnsCache.fromJson(e as Map<String, dynamic>)).toList() : null,
dohCache: json['dohCache'] != null ? (json['dohCache'] as List? ?? []).map((e) => DnsCache.fromJson(e as Map<String, dynamic>)).toList() : null
);

factory DnsConfig.fromJson(Map<String, dynamic> json) => DnsConfig(
enableDoH: json['enableDoH'] != null ? json['enableDoH'] as bool : null,
enableCustomHosts: json['enableCustomHosts'] != null
? json['enableCustomHosts'] as bool
: null,
enableDomainFronting: json['enableDomainFronting'] != null
? json['enableDomainFronting'] as bool
: null,
hosts: json['hosts'] != null
? (json['hosts'] as List? ?? [])
.map((e) => DnsCache.fromJson(e as Map<String, dynamic>))
.toList()
: null,
dohCache: json['dohCache'] != null
? (json['dohCache'] as List? ?? [])
.map((e) => DnsCache.fromJson(e as Map<String, dynamic>))
.toList()
: null);

Map<String, dynamic> toJson() => {
'enableDoH': enableDoH,
'enableCustomHosts': enableCustomHosts,
'enableDomainFronting': enableDomainFronting,
'hosts': hosts?.map((e) => e.toJson()).toList(),
'dohCache': dohCache?.map((e) => e.toJson()).toList()
};
'enableDoH': enableDoH,
'enableCustomHosts': enableCustomHosts,
'enableDomainFronting': enableDomainFronting,
'hosts': hosts?.map((e) => e.toJson()).toList(),
'dohCache': dohCache?.map((e) => e.toJson()).toList()
};

DnsConfig clone() => DnsConfig(
enableDoH: enableDoH,
enableCustomHosts: enableCustomHosts,
enableDomainFronting: enableDomainFronting,
hosts: hosts?.map((e) => e.clone()).toList(),
dohCache: dohCache?.map((e) => e.clone()).toList()
);
enableDoH: enableDoH,
enableCustomHosts: enableCustomHosts,
enableDomainFronting: enableDomainFronting,
hosts: hosts?.map((e) => e.clone()).toList(),
dohCache: dohCache?.map((e) => e.clone()).toList());


DnsConfig copyWith({
bool? enableDoH,
bool? enableCustomHosts,
bool? enableDomainFronting,
List<DnsCache>? hosts,
List<DnsCache>? dohCache
}) => DnsConfig(
enableDoH: enableDoH ?? this.enableDoH,
enableCustomHosts: enableCustomHosts ?? this.enableCustomHosts,
enableDomainFronting: enableDomainFronting ?? this.enableDomainFronting,
hosts: hosts ?? this.hosts,
dohCache: dohCache ?? this.dohCache,
);
DnsConfig copyWith(
{bool? enableDoH,
bool? enableCustomHosts,
bool? enableDomainFronting,
List<DnsCache>? hosts,
List<DnsCache>? dohCache}) =>
DnsConfig(
enableDoH: enableDoH ?? this.enableDoH,
enableCustomHosts: enableCustomHosts ?? this.enableCustomHosts,
enableDomainFronting: enableDomainFronting ?? this.enableDomainFronting,
hosts: hosts ?? this.hosts,
dohCache: dohCache ?? this.dohCache,
);

@override
bool operator ==(Object other) => identical(this, other)
|| other is DnsConfig && enableDoH == other.enableDoH && enableCustomHosts == other.enableCustomHosts && enableDomainFronting == other.enableDomainFronting && hosts == other.hosts && dohCache == other.dohCache;
bool operator ==(Object other) =>
identical(this, other) ||
other is DnsConfig &&
enableDoH == other.enableDoH &&
enableCustomHosts == other.enableCustomHosts &&
enableDomainFronting == other.enableDomainFronting &&
hosts == other.hosts &&
dohCache == other.dohCache;

@override
int get hashCode => enableDoH.hashCode ^ enableCustomHosts.hashCode ^ enableDomainFronting.hashCode ^ hosts.hashCode ^ dohCache.hashCode;
int get hashCode =>
enableDoH.hashCode ^
enableCustomHosts.hashCode ^
enableDomainFronting.hashCode ^
hosts.hashCode ^
dohCache.hashCode;
}
135 changes: 77 additions & 58 deletions lib/models/gallery_comment.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:flutter/foundation.dart';

import 'gallery_comment_span.dart';

@immutable
class GalleryComment {

const GalleryComment({
required this.name,
required this.time,
Expand All @@ -26,69 +26,88 @@ class GalleryComment {
final bool? canVote;
final bool? showTranslate;

factory GalleryComment.fromJson(Map<String,dynamic> json) => GalleryComment(
name: json['name'] as String,
time: json['time'] as String,
span: (json['span'] as List? ?? []).map((e) => GalleryCommentSpan.fromJson(e as Map<String, dynamic>)).toList(),
score: json['score'] as String,
vote: json['vote'] != null ? json['vote'] as int : null,
id: json['id'] != null ? json['id'] as String : null,
canEdit: json['canEdit'] != null ? json['canEdit'] as bool : null,
canVote: json['canVote'] != null ? json['canVote'] as bool : null,
showTranslate: json['showTranslate'] != null ? json['showTranslate'] as bool : null
);

factory GalleryComment.fromJson(Map<String, dynamic> json) => GalleryComment(
name: json['name'] as String,
time: json['time'] as String,
span: (json['span'] as List? ?? [])
.map((e) => GalleryCommentSpan.fromJson(e as Map<String, dynamic>))
.toList(),
score: json['score'] as String,
vote: json['vote'] != null ? json['vote'] as int : null,
id: json['id'] != null ? json['id'] as String : null,
canEdit: json['canEdit'] != null ? json['canEdit'] as bool : null,
canVote: json['canVote'] != null ? json['canVote'] as bool : null,
showTranslate:
json['showTranslate'] != null ? json['showTranslate'] as bool : null);

Map<String, dynamic> toJson() => {
'name': name,
'time': time,
'span': span.map((e) => e.toJson()).toList(),
'score': score,
'vote': vote,
'id': id,
'canEdit': canEdit,
'canVote': canVote,
'showTranslate': showTranslate
};
'name': name,
'time': time,
'span': span.map((e) => e.toJson()).toList(),
'score': score,
'vote': vote,
'id': id,
'canEdit': canEdit,
'canVote': canVote,
'showTranslate': showTranslate
};

GalleryComment clone() => GalleryComment(
name: name,
time: time,
span: span.map((e) => e.clone()).toList(),
score: score,
vote: vote,
id: id,
canEdit: canEdit,
canVote: canVote,
showTranslate: showTranslate
);
name: name,
time: time,
span: span.map((e) => e.clone()).toList(),
score: score,
vote: vote,
id: id,
canEdit: canEdit,
canVote: canVote,
showTranslate: showTranslate);


GalleryComment copyWith({
String? name,
String? time,
List<GalleryCommentSpan>? span,
String? score,
int? vote,
String? id,
bool? canEdit,
bool? canVote,
bool? showTranslate
}) => GalleryComment(
name: name ?? this.name,
time: time ?? this.time,
span: span ?? this.span,
score: score ?? this.score,
vote: vote ?? this.vote,
id: id ?? this.id,
canEdit: canEdit ?? this.canEdit,
canVote: canVote ?? this.canVote,
showTranslate: showTranslate ?? this.showTranslate,
);
GalleryComment copyWith(
{String? name,
String? time,
List<GalleryCommentSpan>? span,
String? score,
int? vote,
String? id,
bool? canEdit,
bool? canVote,
bool? showTranslate}) =>
GalleryComment(
name: name ?? this.name,
time: time ?? this.time,
span: span ?? this.span,
score: score ?? this.score,
vote: vote ?? this.vote,
id: id ?? this.id,
canEdit: canEdit ?? this.canEdit,
canVote: canVote ?? this.canVote,
showTranslate: showTranslate ?? this.showTranslate,
);

@override
bool operator ==(Object other) => identical(this, other)
|| other is GalleryComment && name == other.name && time == other.time && span == other.span && score == other.score && vote == other.vote && id == other.id && canEdit == other.canEdit && canVote == other.canVote && showTranslate == other.showTranslate;
bool operator ==(Object other) =>
identical(this, other) ||
other is GalleryComment &&
name == other.name &&
time == other.time &&
span == other.span &&
score == other.score &&
vote == other.vote &&
id == other.id &&
canEdit == other.canEdit &&
canVote == other.canVote &&
showTranslate == other.showTranslate;

@override
int get hashCode => name.hashCode ^ time.hashCode ^ span.hashCode ^ score.hashCode ^ vote.hashCode ^ id.hashCode ^ canEdit.hashCode ^ canVote.hashCode ^ showTranslate.hashCode;
int get hashCode =>
name.hashCode ^
time.hashCode ^
span.hashCode ^
score.hashCode ^
vote.hashCode ^
id.hashCode ^
canEdit.hashCode ^
canVote.hashCode ^
showTranslate.hashCode;
}
Loading

0 comments on commit 09ad3c5

Please sign in to comment.