From acf8e83cbf106b4350536d54eb46379dd86a623c Mon Sep 17 00:00:00 2001
From: Runt <qingingrunt2010@qq.com>
Date: Fri, 04 Jul 2025 17:05:00 +0000
Subject: [PATCH] 输入弹框 图标修改 相机调整

---
 LiveProject/activity/stream/LiveActivity.swift |  102 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 73 insertions(+), 29 deletions(-)

diff --git a/LiveProject/activity/stream/LiveActivity.swift b/LiveProject/activity/stream/LiveActivity.swift
index ef284a2..57e7890 100644
--- a/LiveProject/activity/stream/LiveActivity.swift
+++ b/LiveProject/activity/stream/LiveActivity.swift
@@ -11,10 +11,9 @@
 import MetalKit
 
 struct LiveActivity: View {
-    @State private var pixelBuffer: CVPixelBuffer?
-    
     
     @State private var showDeviceDialog = false
+    @State private var showInputDialog = false
     
     @State private var streamRate = Float(9/16.0);
     @State private var fpsState = 30;
@@ -22,27 +21,27 @@
     
     @State private var displaySize : CGSize = .zero;
     
-    @State private var devices = [DeviceInfo(name: "相机", type: .CAMERA, deviceId: UUID().uuidString,icon: IconCamera()),
-                                  DeviceInfo(name: "话筒", type: .MICROPHONE,deviceId: UUID().uuidString,icon: IconMic()),
-                                  DeviceInfo(name: "系统", type: .SYSTEM,deviceId : UUID().uuidString,icon: IconPortrait())]
+    @State private var devices = [DeviceInfo(name: "相机", type: .CAMERA, deviceId: UUID().uuidString,icon: Icons.CAMERA),
+                                  DeviceInfo(name: "话筒", type: .MICROPHONE,deviceId: UUID().uuidString,icon: Icons.MIC),
+                                  DeviceInfo(name: "系统", type: .SYSTEM,deviceId : UUID().uuidString,icon: Icons.PORTRAIT)]
 
     
-    private let mViewModel = LiveViewModel()
+    @StateObject private var mViewModel = LiveViewModel()
     
     var body: some View {
         ZStack{
             Color.clear
                 .ignoresSafeArea() // 填满全屏
             VStack{
-                VideoRendererView(renderer:mViewModel.renderer).background(Color.black).frame(width: mainSize.width,height:mainSize.height)
+                VideoRendererView(pixelBuffer: $mViewModel.pixelBuffer).background(Color.black).frame(width: mainSize.width,height:mainSize.height)
                 Spacer()
             }.border(Color.blue)
             VStack{
                 Spacer()
                 BottomBtns().frame(alignment: .bottom).border(Color.green)
             }
-            if showDeviceDialog {
-                DialogDevices()
+            if showInputDialog{
+                DialogInput()
             }
         }.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading)
             .background(
@@ -99,20 +98,59 @@
         print("updateWindow:\(mainSize)")
     }
     
-    func DialogDevices() -> some View{
+    func DialogInput(onCancel:() ->Void = {},onConfirm:() -> Void = {}) -> some View{
         ZStack{
             Color.black.opacity(0.4)
                 .edgesIgnoringSafeArea(.all)
                 .onTapGesture {
                     withAnimation {
-                        showDeviceDialog = false
+                        showInputDialog = false
                     }
                 }
             VStack {
-                Spacer()
-                VStack(spacing: 20) {
-                    Spacer().frame(height:40)
-                    FlowLayout(devices){ device in
+                VStack(alignment: .leading, spacing: 40) {
+                    Text("请输入直播地址")
+                        .font(Font.system(size: 20))
+                    LTextField().environmentObject(LText())
+                    HStack{
+                     Spacer()
+                        Button(action:{
+                            showInputDialog.toggle();
+                        }){
+                            Text("取消")
+                                .font(Font.system(size: 20))
+                                .foregroundColor(Color.gray)
+                        }
+                        
+                        Spacer().frame(width: 30)
+                        Button(action:{
+                            showInputDialog.toggle();
+                        }){
+                            Text("确认")
+                                .font(Font.system(size: 20))
+                                .foregroundColor(Color.colorTextLink)
+                        }
+                        
+                    }
+                }
+                .padding(30)
+                .background(Color.white)
+                .cornerRadius(20)
+                .transition(.move(edge: .bottom))
+            }
+            .padding(60)
+            .zIndex(1)
+            .animation(.default, value: devices)
+        }
+    }
+    
+    func DialogDevices() -> some View{
+        VStack{
+            VStack(spacing: 20) {
+                Spacer().frame(height:20)
+                FlowLayout(){
+                    
+                    ForEach(devices, id: \.self) { device in
                         MButton(icon: device.icon,text: device.name){
                             mViewModel.newWindowAction(device: device){ status in
                                 withAnimation{
@@ -122,17 +160,12 @@
                             print("\(device.name) click")
                         }
                     }
-                    .padding()
                 }
-                .frame(maxWidth: .infinity)
-                .padding()
-                .background(Color.white)
-                .cornerRadius(20)
-                .transition(.move(edge: .bottom))
             }
-            .zIndex(1)
-            .animation(.default, value: devices)
+            .frame(maxWidth: .infinity,alignment:.leading)
+            .padding()
         }
+        .frame(maxHeight: .infinity,alignment:.topLeading)
     }
     
     func BottomBtns() -> some View{
@@ -140,7 +173,7 @@
         
             HStack(){
                 //横竖屏控制
-                MButton(icon:streamRate == (9/16.0) ? IconPortrait() : IconLandscape() ){
+                MButton(icon:streamRate == (9/16.0) ? Icons.PORTRAIT : Icons.LANDSCAPE ){
                     streamRate = streamRate == (9/16.0) ? (16/9.0) : (9/16.0)
                     updateWindowSize()
                 }
@@ -156,18 +189,29 @@
             HStack{
                 LButton(text: "设备"){
                     print("Click 设备 button")
-                    withAnimation{
-                        showDeviceDialog.toggle()
+                    showDeviceDialog.toggle()
+                }.sheet(isPresented:$showDeviceDialog, content: {
+                    VStack {
+                        ScrollView {
+                            DialogDevices()
+                        }
                     }
-                }
+                    .presentationDetents([.height(200),.medium])
+                })
                 LButton(text: "RTMP"){
-                    
+                    print("Click RTMP button")
+                    withAnimation{
+                        showInputDialog.toggle()
+                    }
                 }
                 /*flLButton(text: "文件"){
                     
                 }*/
                 LButton(text: "文本"){
-                    
+                    print("Click 文本 button")
+                    withAnimation{
+                        showInputDialog.toggle()
+                    }
                 }
             }
             HStack{

--
Gitblit v1.9.1