Commit 339fa4019a2eb0be8d917797da6e9b8a321bd8ba

Authored by 权海
1 parent dd1f741d

feat(ui):首页/好友页互动入口

5.01 KB | W: | H:

2.25 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin

4.69 KB | W: | H:

2.98 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -163,7 +163,7 @@ class TodayTabBody extends StatelessWidget {
if (controller.isFriend || showInteractionEntry)
const Positioned(
right: 16,
bottom: 92,
bottom: 160,
child: FriendInteractionFloatingEntry(),
),
],
... ...
... ... @@ -15,7 +15,7 @@ class TodayHrvNumberCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
padding: const EdgeInsets.symmetric(vertical: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
... ... @@ -87,7 +87,7 @@ class _NumberItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
padding: const EdgeInsets.only(left: 20, right: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
... ... @@ -105,11 +105,8 @@ class _NumberItem extends StatelessWidget {
),
),
),
if (interactionEnabled != null)
FriendInteractionButton(enabled: interactionEnabled!),
],
),
const SizedBox(height: 6),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
... ... @@ -124,7 +121,7 @@ class _NumberItem extends StatelessWidget {
),
const SizedBox(width: 4),
Padding(
padding: const EdgeInsets.only(bottom: 3),
padding: const EdgeInsets.only(bottom: 0),
child: Text(
unit,
style: TextStyle(
... ... @@ -134,6 +131,18 @@ class _NumberItem extends StatelessWidget {
),
),
),
if (interactionEnabled != null) ...[
const SizedBox(width: 8),
FriendInteractionButton(
enabled: interactionEnabled!,
padding: const EdgeInsets.only(
left: 8,
right: 20,
top: 8,
bottom: 0,
),
),
],
],
),
],
... ...
... ... @@ -458,7 +458,7 @@ class _TodaySummaryCard extends StatelessWidget {
return Container(
margin: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.fromLTRB(20, 18, 20, 15),
padding: const EdgeInsets.fromLTRB(20, 10, 10, 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
... ... @@ -477,28 +477,20 @@ class _TodaySummaryCard extends StatelessWidget {
fontWeight: FontWeight.w600,
),
),
if (interactionEnabled != null) ...[
const SizedBox(width: 8),
FriendInteractionButton(enabled: interactionEnabled!),
],
const Spacer(),
Text(
actionText,
style: TextStyle(
color: colors.textSecondary,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
SizedBox(width: 4),
Image.asset(
'assets/images/common/ic_more_gray.png',
width: 16,
height: 16,
color: colors.textTertiary,
),
const Spacer(),
if (interactionEnabled != null) ...[
FriendInteractionButton(enabled: interactionEnabled!),
],
],
),
const SizedBox(height: 16),
const SizedBox(height: 8),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
... ...
... ... @@ -6,11 +6,18 @@ class FriendInteractionButton extends StatelessWidget {
const FriendInteractionButton({
super.key,
required this.enabled,
this.size = 24,
this.size = 24,
this.padding = const EdgeInsets.only(
left: 20,
right: 10,
top: 8,
bottom: 8,
),
});
final bool enabled;
final double size;
final EdgeInsets padding;
@override
Widget build(BuildContext context) => Opacity(
... ... @@ -18,18 +25,12 @@ class FriendInteractionButton extends StatelessWidget {
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: enabled ? _openInteraction : null,
child: SizedBox(
width: size,
height: size,
child: DecoratedBox(
decoration: const BoxDecoration(
color: Color(0xFF845EEE),
shape: BoxShape.circle,
),
child: Padding(
padding: EdgeInsets.all(size / 8),
child: Image.asset('assets/images/interact/icon_stick.png'),
),
child: Padding(
padding: padding,
child: SizedBox(
width: size,
height: size,
child: Image.asset('assets/images/interact/icon_stick.png'),
),
),
),
... ...
... ... @@ -2136,6 +2136,11 @@ double _integerDouble(num value) => value.toInt().toDouble();
int _unixSecondsNow() => DateTime.now().millisecondsSinceEpoch ~/ 1000;
class HealthRawStressLocalStore {
// Version 12 deliberately re-runs the date-key migration. Some shipped
// databases were stamped with version 11 before this column was present.
// SQLite consequently skips the old (< 9) migration for those databases.
static const _databaseVersion = 12;
HealthRawStressLocalStore({
Directory? rootDirectory,
DatabaseFactory? databaseFactory,
... ... @@ -2625,7 +2630,7 @@ class HealthRawStressLocalStore {
final db = await factory.openDatabase(
path,
options: OpenDatabaseOptions(
version: 11,
version: _databaseVersion,
onCreate: (db, version) async {
await _createTables(db);
},
... ... @@ -2661,9 +2666,17 @@ class HealthRawStressLocalStore {
if (oldVersion < 11) {
await _createIndexes(db);
}
if (oldVersion < _databaseVersion) {
await _repairDateKeySchema(db);
}
},
),
);
// Do not rely exclusively on user_version here. Historical releases may
// have recorded the target version even though their schema migration did
// not complete. This is idempotent, so it also protects a database whose
// migration was interrupted before the app was terminated.
await _repairDateKeySchema(db);
_opened[userId] = db;
return db;
}
... ... @@ -2842,6 +2855,10 @@ CREATE TABLE IF NOT EXISTS $sleepResultsTable (
}
}
Future<void> _repairDateKeySchema(DatabaseExecutor db) async {
await _addDateKeyColumns(db);
}
Future<void> _addPushSendTimeColumns(DatabaseExecutor db) async {
for (final table in const [
hrvResultsTable,
... ...
... ... @@ -10,6 +10,10 @@ import 'huawei_health_data_type.dart';
import 'ohos_health_raw_data_sync_service.dart';
class OhosHealthRawDataSqliteStore implements OhosHealthRawDataLocalStore {
// Re-run the date-key repair for databases that were marked as v2 before
// their dynamic raw-data tables completed the v2 migration.
static const _databaseVersion = 3;
OhosHealthRawDataSqliteStore({
required int Function()? userIdProvider,
Directory? rootDirectory,
... ... @@ -417,15 +421,22 @@ class OhosHealthRawDataSqliteStore implements OhosHealthRawDataLocalStore {
final db = await factory.openDatabase(
path,
options: OpenDatabaseOptions(
version: 2,
version: _databaseVersion,
onCreate: (db, version) => _createTables(db),
onUpgrade: (db, oldVersion, newVersion) async {
if (oldVersion < 2) {
await _addDateKeyColumns(db);
}
if (oldVersion < _databaseVersion) {
await _repairDateKeySchema(db);
}
},
),
);
// Dynamic raw-data tables can be created while a prior app version is
// running. Do not trust user_version alone: make their date-key schema
// valid before any read or write uses the cached database handle.
await _repairDateKeySchema(db);
_opened[userId] = db;
return db;
}
... ... @@ -703,6 +714,10 @@ CREATE TABLE IF NOT EXISTS $table (
}
}
Future<void> _repairDateKeySchema(DatabaseExecutor db) async {
await _addDateKeyColumns(db);
}
Future<void> _backfillDateKey(DatabaseExecutor db, String table) async {
final columns = await db.rawQuery('PRAGMA table_info($table)');
final columnNames =
... ...
... ... @@ -138,3 +138,5 @@ flutter:
- assets/images/user_onboarding/oh/
- assets/images/premium/
- assets/images/premium/zh/
- assets/images/interact/
- assets/images/interact/animations/
\ No newline at end of file
... ...