Skip to content

Commit

Permalink
【flutter】【demo】【flutter】【demo】Sample Demo code structure, logic optim…
Browse files Browse the repository at this point in the history
…ization
  • Loading branch information
iveshzf authored and MinTate committed Mar 8, 2024
1 parent 57a32db commit 50803e8
Show file tree
Hide file tree
Showing 18 changed files with 2,844 additions and 3,190 deletions.
20 changes: 9 additions & 11 deletions TRTC-Simple-Demo/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:trtc_demo/page/trtcmeetingdemo/index.dart';
import 'package:trtc_demo/page/trtcmeetingdemo/meeting.dart';
import 'package:trtc_demo/page/trtcmeetingdemo/member_list.dart';
import 'package:trtc_demo/page/trtcmeetingdemo/test_api.dart';
import 'package:trtc_demo/models/meeting.dart';
import 'package:trtc_demo/page/trtcmeetingdemo/texture_render.dart';
import 'package:trtc_demo/page/trtcmeetingdemo/test_web.dart';
import 'package:trtc_demo/ui/login.dart';
import 'package:trtc_demo/ui/meeting.dart';
import 'package:trtc_demo/ui/member_list.dart';
import 'package:trtc_demo/ui/test/test_api.dart';
import 'package:trtc_demo/models/meeting_model.dart';
import 'package:trtc_demo/ui/test/test_web.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -29,10 +28,9 @@ class _MyAppState extends State<MyApp> {
create: (context) => MeetingModel(),
child: MaterialApp(
routes: {
"/": (context) => IndexPage(),
"/index": (context) => IndexPage(),
"/video": (context) => MeetingPage(),
"/textureRender": (context) => TextureRenderPage(),
"/": (context) => LoginPage(),
"/login": (context) => LoginPage(),
"/meeting": (context) => MeetingPage(),
"/memberList": (context) => MemberListPage(),
"/test": (context) => TestPage(),
"/testweb": (context) => TestWebPage()
Expand Down
14 changes: 14 additions & 0 deletions TRTC-Simple-Demo/lib/models/data_models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

class WidgetSize {
int width;
int height;

WidgetSize({required int this.width, required int this.height});
}

enum BeautyType {
smooth,
nature,
pitu,
ruddy,
}
45 changes: 0 additions & 45 deletions TRTC-Simple-Demo/lib/models/meeting.dart

This file was deleted.

72 changes: 72 additions & 0 deletions TRTC-Simple-Demo/lib/models/meeting_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import 'dart:collection';

import 'package:flutter/foundation.dart';
import 'package:tencent_trtc_cloud/trtc_cloud_def.dart';
import 'package:trtc_demo/models/data_models.dart';
import 'package:trtc_demo/models/user_model.dart';

class MeetingModel extends ChangeNotifier {
/// Internal, private state of the cart.
int? _meetId;
bool _isTextureRendering = false;
int _quality = TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT;

late UserModel _userInfo;
List<UserModel> _userList = [];

Map<BeautyType, double> _beautyInfo = {
BeautyType.smooth : 6,
BeautyType.nature : 6,
BeautyType.pitu : 6,
BeautyType.ruddy : 0
};

void setList(list) {
_userList = list;
notifyListeners();
}

void setUserSettings(
{required int meetId,
required String userId,
required bool enabledCamera,
required bool enabledMicrophone,
required bool enableTextureRendering,
int? quality = null}) {
_meetId = meetId;
_userInfo = UserModel(userId: userId);
_userInfo.isOpenCamera = enabledCamera;
_userInfo.isOpenMic = enabledMicrophone;
_isTextureRendering = enableTextureRendering;
_quality = quality ?? TRTCCloudDef.TRTC_AUDIO_QUALITY_DEFAULT;
}

int? getMeetId() {
return _meetId;
}

int getQuality() {
return _quality;
}

Map getBeautyInfo() {
return _beautyInfo;
}

bool getTextureRenderingEnable() {
return _isTextureRendering;
}

UserModel getUserInfo() {
return _userInfo;
}

List<UserModel> getList() {
return _userList;
}

void removeAll() {
_userList.clear();
notifyListeners();
}
}
24 changes: 24 additions & 0 deletions TRTC-Simple-Demo/lib/models/user_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


import 'package:trtc_demo/models/data_models.dart';

class UserModel {
String userId;
String? userSig;

String type = 'video';
WidgetSize size = WidgetSize(width: 0, height: 0);

bool enableAudio = true;
bool enableVideo = true;

bool isOpenMic = true;
bool isOpenCamera = false;
bool isFrontCamera = true;
bool isSpeak = true;
bool isShowingWindow = false;
int? localViewId;
bool isShowBeauty = true;

UserModel({required String this.userId});
}
Loading

0 comments on commit 50803e8

Please sign in to comment.