Browse Source

首页修改

桂欢 1 year ago
parent
commit
1263c9b041

+ 10 - 10
SLAiELTS/SLAiELTS.xcodeproj/project.pbxproj

@@ -101,8 +101,6 @@
 		3D2D8BF829DE5AE4009392DA /* SCIndexViewConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D8BF229DE5AE4009392DA /* SCIndexViewConfiguration.m */; };
 		3D2D8BF929DE5AE4009392DA /* SCIndexView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D8BF429DE5AE4009392DA /* SCIndexView.m */; };
 		3D2D8BFA29DE5AE5009392DA /* UITableView+SCIndexView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D8BF629DE5AE4009392DA /* UITableView+SCIndexView.m */; };
-		3D2D8BFE29DE6389009392DA /* SLHomeMsgCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D8BFC29DE6389009392DA /* SLHomeMsgCollectionViewCell.m */; };
-		3D2D8BFF29DE6389009392DA /* SLHomeMsgCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3D2D8BFD29DE6389009392DA /* SLHomeMsgCollectionViewCell.xib */; };
 		3D2D8C0329DE7288009392DA /* SLCustNavView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D8C0129DE7287009392DA /* SLCustNavView.m */; };
 		3D2D8C0729DE7404009392DA /* LeftImageDesignTxtxField.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D8C0529DE7404009392DA /* LeftImageDesignTxtxField.m */; };
 		3D2DC3B529B06D6D0041A729 /* nuisdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D2DC3B329B06D200041A729 /* nuisdk.framework */; };
@@ -145,6 +143,8 @@
 		3D8C9F8729AC57F300678283 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D8C9F8629AC57F300678283 /* Assets.xcassets */; };
 		3D8C9F8A29AC57F300678283 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D8C9F8829AC57F300678283 /* LaunchScreen.storyboard */; };
 		3D8C9F8D29AC57F300678283 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D8C9F8C29AC57F300678283 /* main.m */; };
+		3D8EBBC72A131FA40008B0C1 /* SLHomeMsgTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D8EBBC52A131FA40008B0C1 /* SLHomeMsgTableViewCell.m */; };
+		3D8EBBC82A131FA40008B0C1 /* SLHomeMsgTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3D8EBBC62A131FA40008B0C1 /* SLHomeMsgTableViewCell.xib */; };
 		3D9961F929CD2EFE0076DBD1 /* SLNestSubjectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9961F529CD2EFD0076DBD1 /* SLNestSubjectViewController.m */; };
 		3D9961FA29CD2EFE0076DBD1 /* SLNestViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9961F829CD2EFE0076DBD1 /* SLNestViewController.m */; };
 		3D9961FD29CD2FB00076DBD1 /* SLContentBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D9961FB29CD2FAF0076DBD1 /* SLContentBaseViewController.m */; };
@@ -439,9 +439,6 @@
 		3D2D8BF529DE5AE4009392DA /* SCIndexViewConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCIndexViewConfiguration.h; sourceTree = "<group>"; };
 		3D2D8BF629DE5AE4009392DA /* UITableView+SCIndexView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableView+SCIndexView.m"; sourceTree = "<group>"; };
 		3D2D8BF729DE5AE4009392DA /* SCIndexView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCIndexView.h; sourceTree = "<group>"; };
-		3D2D8BFB29DE6389009392DA /* SLHomeMsgCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SLHomeMsgCollectionViewCell.h; sourceTree = "<group>"; };
-		3D2D8BFC29DE6389009392DA /* SLHomeMsgCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SLHomeMsgCollectionViewCell.m; sourceTree = "<group>"; };
-		3D2D8BFD29DE6389009392DA /* SLHomeMsgCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SLHomeMsgCollectionViewCell.xib; sourceTree = "<group>"; };
 		3D2D8C0129DE7287009392DA /* SLCustNavView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLCustNavView.m; sourceTree = "<group>"; };
 		3D2D8C0229DE7288009392DA /* SLCustNavView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLCustNavView.h; sourceTree = "<group>"; };
 		3D2D8C0529DE7404009392DA /* LeftImageDesignTxtxField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeftImageDesignTxtxField.m; sourceTree = "<group>"; };
@@ -517,6 +514,9 @@
 		3D8C9F8929AC57F300678283 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		3D8C9F8B29AC57F300678283 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		3D8C9F8C29AC57F300678283 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+		3D8EBBC42A131FA40008B0C1 /* SLHomeMsgTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SLHomeMsgTableViewCell.h; sourceTree = "<group>"; };
+		3D8EBBC52A131FA40008B0C1 /* SLHomeMsgTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SLHomeMsgTableViewCell.m; sourceTree = "<group>"; };
+		3D8EBBC62A131FA40008B0C1 /* SLHomeMsgTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SLHomeMsgTableViewCell.xib; sourceTree = "<group>"; };
 		3D9961F529CD2EFD0076DBD1 /* SLNestSubjectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLNestSubjectViewController.m; sourceTree = "<group>"; };
 		3D9961F629CD2EFD0076DBD1 /* SLNestViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLNestViewController.h; sourceTree = "<group>"; };
 		3D9961F729CD2EFD0076DBD1 /* SLNestSubjectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLNestSubjectViewController.h; sourceTree = "<group>"; };
@@ -1811,9 +1811,9 @@
 				3D1B9D0929C2A1360008D01A /* SLPlaceholderCell.h */,
 				3D1B9D0A29C2A1360008D01A /* SLPlaceholderCell.m */,
 				3D1B9D0B29C2A1360008D01A /* SLPlaceholderCell.xib */,
-				3D2D8BFB29DE6389009392DA /* SLHomeMsgCollectionViewCell.h */,
-				3D2D8BFC29DE6389009392DA /* SLHomeMsgCollectionViewCell.m */,
-				3D2D8BFD29DE6389009392DA /* SLHomeMsgCollectionViewCell.xib */,
+				3D8EBBC42A131FA40008B0C1 /* SLHomeMsgTableViewCell.h */,
+				3D8EBBC52A131FA40008B0C1 /* SLHomeMsgTableViewCell.m */,
+				3D8EBBC62A131FA40008B0C1 /* SLHomeMsgTableViewCell.xib */,
 			);
 			path = Cells;
 			sourceTree = "<group>";
@@ -1893,6 +1893,7 @@
 				3DF3DAB329B9B86200CAD3AB /* SLUserCenterViewController.xib in Resources */,
 				3DB97D6C29D6ABC100B12754 /* sdRefeshView_arrow@2x.png in Resources */,
 				3D25106129AC95A9000AE530 /* SLRetrievePWViewController.xib in Resources */,
+				3D8EBBC82A131FA40008B0C1 /* SLHomeMsgTableViewCell.xib in Resources */,
 				3DF3DAA829B9A6AA00CAD3AB /* SLBaseCellView.xib in Resources */,
 				3DF3DAE529BAFCCA00CAD3AB /* SLMySpeedCollectionViewCell.xib in Resources */,
 				3D24986D29AC72E2003C3AFA /* SLLoginVCViewController.xib in Resources */,
@@ -1939,7 +1940,6 @@
 				3D6EE45429F2568000B02EBB /* SLRecomFriendsVc.xib in Resources */,
 				3D2DC3F629B1E6510041A729 /* SLMikeInputView.xib in Resources */,
 				3DB069F929F7A71F005730D7 /* SLFriendPowerVc.xib in Resources */,
-				3D2D8BFF29DE6389009392DA /* SLHomeMsgCollectionViewCell.xib in Resources */,
 				3D25105C29AC9475000AE530 /* SLForgetPWViewController.xib in Resources */,
 				3DB97DA529D6ABF000B12754 /* README.md in Resources */,
 				3DB97D9629D6ABF000B12754 /* MLEmoji_Expression.bundle in Resources */,
@@ -2052,6 +2052,7 @@
 				3D2DC3BF29B0709F0041A729 /* NLSRingBuffer.mm in Sources */,
 				3D25108829ADD46C000AE530 /* SLRoleLabelView.m in Sources */,
 				3D2510D129AF3DC4000AE530 /* SLLoginInfo.m in Sources */,
+				3D8EBBC72A131FA40008B0C1 /* SLHomeMsgTableViewCell.m in Sources */,
 				3D8C9F8229AC57F200678283 /* ViewController.m in Sources */,
 				3D1F17AE2A0DE55D00F030AD /* SLLocationManager.m in Sources */,
 				3D24987429AC7909003C3AFA /* UIViewController+Extension.m in Sources */,
@@ -2088,7 +2089,6 @@
 				3D2D8BF929DE5AE4009392DA /* SCIndexView.m in Sources */,
 				3D8C9F7C29AC57F200678283 /* AppDelegate.mm in Sources */,
 				3D2DC3C029B0709F0041A729 /* NLSVoiceRecorder.m in Sources */,
-				3D2D8BFE29DE6389009392DA /* SLHomeMsgCollectionViewCell.m in Sources */,
 				3D1B989329BEF5960008D01A /* SLLxView.m in Sources */,
 				3D99620029CD2FFA0076DBD1 /* SLListViewController.m in Sources */,
 				3D2510B929AF1970000AE530 /* SLHttpCenter.m in Sources */,

+ 6 - 6
SLAiELTS/SLAiELTS/ViewControllers/Home/Models/SLPageViewModel.m

@@ -49,12 +49,12 @@
 }
 
 + (NSMutableArray<SLPageViewModel *> *)homePageViewModelsWith:(NSArray *)chatList {    NSMutableArray<SLPageViewModel *> *viewModels = [NSMutableArray array];
-    [chatList enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        SLPageModel *model1 = [[SLPageModel alloc] init];
-        model1.chatListModel = obj;
-        SLPageViewModel *vm1 = [[SLPageViewModel alloc] initWith:model1 cellClass:SLHomeMsgCollectionViewCell.class viewSize:CGSizeMake(kSCREEN_WIDTH, 74 * KScaleW) headerSize:CGSizeMake(kSCREEN_WIDTH, 0)];
-        [viewModels addObject:vm1];
-    }];
+//    [chatList enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+//        SLPageModel *model1 = [[SLPageModel alloc] init];
+//        model1.chatListModel = obj;
+//        SLPageViewModel *vm1 = [[SLPageViewModel alloc] initWith:model1 cellClass:SLHomeMsgCollectionViewCell.class viewSize:CGSizeMake(kSCREEN_WIDTH, 74 * KScaleW) headerSize:CGSizeMake(kSCREEN_WIDTH, 0)];
+//        [viewModels addObject:vm1];
+//    }];
     SLPageModel *model4 = [[SLPageModel alloc] init];
     SLPageViewModel *vm4 = [[SLPageViewModel alloc] initWith:model4 cellClass:SLPlaceholderCell.class viewSize:CGSizeMake(kSCREEN_WIDTH, 20) headerSize:CGSizeMake(kSCREEN_WIDTH, 0)];
     [viewModels addObject:vm4];

+ 5 - 5
SLAiELTS/SLAiELTS/ViewControllers/Home/SLHomeViewController.m

@@ -22,7 +22,7 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view from its nib.
     if (@available(iOS 11.0, *)) {
-        self.homeView.mainCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
+        self.homeView.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
     } else {
         self.automaticallyAdjustsScrollViewInsets = NO;
     }
@@ -31,9 +31,9 @@
     }];
     self.navigationBar.hidden = YES;
     WS(weakSelf);
-    self.homeView.mainCollectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
+    self.homeView.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
         [weakSelf requestChatList:^{
-            weakSelf.homeView.mainCollectionView.mj_header.state = MJRefreshStateIdle;
+            weakSelf.homeView.tableView.mj_header.state = MJRefreshStateIdle;
         }];
     }];
 }
@@ -52,8 +52,8 @@
         [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Chat/GetChatList" parameter:@{} success:^(id responseObject) {
             NSArray *chatList = [responseObject objectForKey:@"data"];
             self.chatList = [SLChatListModel mj_objectArrayWithKeyValuesArray:chatList];
-            self.homeView.viewModels = [SLPageViewModel homePageViewModelsWith:self.chatList];
-            [self.homeView.mainCollectionView reloadData];
+            self.homeView.viewModels = self.chatList;
+            [self.homeView.tableView reloadData];
             compBlock();
         } failure:^(SPRequestError *error) {
             compBlock();

+ 0 - 27
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/Cells/SLHomeMsgCollectionViewCell.m

@@ -1,27 +0,0 @@
-//
-//  SLHomeMsgCollectionViewCell.m
-//  SLAiELTS
-//
-//  Created by Gusont on 2023/4/6.
-//
-
-#import "SLHomeMsgCollectionViewCell.h"
-
-@implementation SLHomeMsgCollectionViewCell
-
-- (void)awakeFromNib {
-    [super awakeFromNib];
-    // Initialization code
-//    [self.headImageView showBadgeWithStyle:WBadgeStyleNumber value:10 animationType:WBadgeAnimTypeNone];
-//    self.headImageView.badgeCenterOffset = CGPointMake(-8, 8);
-}
-
-- (void)confignCellWithModel:(SLPageModel *)pageMode {
-    NSString *userImg = [NSString stringWithFormat:@"%@%@",[SLHttpCenter SharedInstance].serverUrl, pageMode.chatListModel.dataHead];
-    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:userImg] placeholderImage:ImageName(@"icon_ellipse")];
-    self.nameLabel.text = pageMode.chatListModel.dataName;
-    self.msgLabel.text = [NSString replaceHasPrefix:@"\n" str:pageMode.chatListModel.message];
-    self.timeLabel.text = pageMode.chatListModel.sendDate;
-}
-
-@end

+ 7 - 3
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/Cells/SLHomeMsgCollectionViewCell.h → SLAiELTS/SLAiELTS/ViewControllers/Home/Views/Cells/SLHomeMsgTableViewCell.h

@@ -1,21 +1,25 @@
 //
-//  SLHomeMsgCollectionViewCell.h
+//  SLHomeMsgTableViewCell.h
 //  SLAiELTS
 //
-//  Created by Gusont on 2023/4/6.
+//  Created by Gusont on 2023/5/16.
 //
 
 #import <UIKit/UIKit.h>
+#import "SLChatListModel.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface SLHomeMsgCollectionViewCell : UICollectionViewCell
+@interface SLHomeMsgTableViewCell : UITableViewCell
+
 @property (weak, nonatomic) IBOutlet UIImageView *headImageView;
 @property (weak, nonatomic) IBOutlet UILabel *nameLabel;
 @property (weak, nonatomic) IBOutlet UILabel *msgLabel;
 
 @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
 
+- (void)confignCellWithModel:(SLChatListModel *)chatMode;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 32 - 0
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/Cells/SLHomeMsgTableViewCell.m

@@ -0,0 +1,32 @@
+//
+//  SLHomeMsgTableViewCell.m
+//  SLAiELTS
+//
+//  Created by Gusont on 2023/5/16.
+//
+
+#import "SLHomeMsgTableViewCell.h"
+
+@implementation SLHomeMsgTableViewCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+
+- (void)confignCellWithModel:(SLChatListModel *)chatMode {
+  NSString *userImg = [NSString stringWithFormat:@"%@%@",[SLHttpCenter SharedInstance].serverUrl, chatMode.dataHead];
+    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:userImg] placeholderImage:ImageName(@"icon_ellipse")];
+    self.nameLabel.text = chatMode.dataName;
+    self.msgLabel.text = [NSString replaceHasPrefix:@"\n" str:chatMode.message];
+    self.timeLabel.text = chatMode.sendDate;
+}
+
+@end

+ 51 - 52
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/Cells/SLHomeMsgCollectionViewCell.xib → SLAiELTS/SLAiELTS/ViewControllers/Home/Views/Cells/SLHomeMsgTableViewCell.xib

@@ -1,30 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
-    <device id="retina6_0" orientation="portrait" appearance="light"/>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina6_12" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="SLHomeMsgCollectionViewCell">
-            <rect key="frame" x="0.0" y="0.0" width="457" height="105"/>
-            <autoresizingMask key="autoresizingMask"/>
-            <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
-                <rect key="frame" x="0.0" y="0.0" width="457" height="105"/>
-                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+        <tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" rowHeight="117" id="KGk-i7-Jjw" customClass="SLHomeMsgTableViewCell">
+            <rect key="frame" x="0.0" y="0.0" width="389" height="117"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
+                <rect key="frame" x="0.0" y="0.0" width="389" height="117"/>
+                <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uw9-ge-7Je">
-                        <rect key="frame" x="0.0" y="0.0" width="457" height="105"/>
+                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iy0-4M-8sM">
+                        <rect key="frame" x="0.0" y="0.0" width="389" height="117"/>
                         <subviews>
-                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_ellipse" translatesAutoresizingMaskIntoConstraints="NO" id="GOG-Kd-9jG">
-                                <rect key="frame" x="16" y="28.666666666666671" width="48" height="48"/>
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_ellipse" translatesAutoresizingMaskIntoConstraints="NO" id="2mQ-9u-Y6h">
+                                <rect key="frame" x="16" y="34.666666666666664" width="48" height="47.999999999999993"/>
                                 <constraints>
-                                    <constraint firstAttribute="width" constant="48" id="AUL-Ml-lNa"/>
-                                    <constraint firstAttribute="width" secondItem="GOG-Kd-9jG" secondAttribute="height" id="OIO-PS-uHj"/>
+                                    <constraint firstAttribute="width" secondItem="2mQ-9u-Y6h" secondAttribute="height" id="xem-vv-Mlb"/>
+                                    <constraint firstAttribute="width" constant="48" id="znM-lN-t0W"/>
                                 </constraints>
                                 <userDefinedRuntimeAttributes>
                                     <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
@@ -32,68 +32,67 @@
                                     </userDefinedRuntimeAttribute>
                                 </userDefinedRuntimeAttributes>
                             </imageView>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="用户名称" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ajS-0W-q0R">
-                                <rect key="frame" x="72" y="28.666666666666671" width="65.333333333333314" height="24"/>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="用户名称" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="11s-ic-gAj">
+                                <rect key="frame" x="72" y="34.666666666666664" width="65.333333333333314" height="24"/>
                                 <constraints>
-                                    <constraint firstAttribute="height" constant="24" id="Edz-KT-CyT"/>
+                                    <constraint firstAttribute="height" constant="24" id="OWi-ba-VT0"/>
                                 </constraints>
                                 <fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="一段很长很长的内容文字" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3JG-RE-eo7">
-                                <rect key="frame" x="72" y="56.666666666666664" width="373" height="15.666666666666664"/>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="一段很长很长的内容文字" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WSp-se-8ET">
+                                <rect key="frame" x="72" y="62.666666666666664" width="305" height="15.666666666666664"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                 <color key="textColor" systemColor="systemGray2Color"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="一段很长很长的内容文字" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GVf-Ac-B6w">
-                                <rect key="frame" x="299" y="32.666666666666664" width="146" height="15.666666666666664"/>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="一段很长很长的内容文字" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LLH-Q9-45f">
+                                <rect key="frame" x="231" y="38.666666666666664" width="146" height="15.666666666666664"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                 <color key="textColor" systemColor="systemGray2Color"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XA3-0v-ZPV">
-                                <rect key="frame" x="72" y="104" width="385" height="1"/>
-                                <color key="backgroundColor" red="0.94901960784313721" green="0.95294117647058818" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hJc-MH-D5J">
+                                <rect key="frame" x="72" y="116" width="317" height="1"/>
+                                <color key="backgroundColor" red="0.94901960780000005" green="0.95294117649999999" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <constraints>
-                                    <constraint firstAttribute="height" constant="1" id="V2z-o7-gCD"/>
+                                    <constraint firstAttribute="height" constant="1" id="WON-GT-wP8"/>
                                 </constraints>
                             </view>
                         </subviews>
                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
-                            <constraint firstItem="GOG-Kd-9jG" firstAttribute="leading" secondItem="uw9-ge-7Je" secondAttribute="leading" constant="16" id="0AR-Jz-ot2"/>
-                            <constraint firstItem="ajS-0W-q0R" firstAttribute="leading" secondItem="GOG-Kd-9jG" secondAttribute="trailing" constant="8" id="3Vh-XH-PEF"/>
-                            <constraint firstItem="ajS-0W-q0R" firstAttribute="top" secondItem="GOG-Kd-9jG" secondAttribute="top" id="40q-Zg-BZ7"/>
-                            <constraint firstItem="GOG-Kd-9jG" firstAttribute="centerY" secondItem="uw9-ge-7Je" secondAttribute="centerY" id="AE4-KE-PSI"/>
-                            <constraint firstAttribute="bottom" secondItem="XA3-0v-ZPV" secondAttribute="bottom" id="LgG-oQ-dm0"/>
-                            <constraint firstItem="XA3-0v-ZPV" firstAttribute="leading" secondItem="3JG-RE-eo7" secondAttribute="leading" id="N9b-o1-aRe"/>
-                            <constraint firstItem="3JG-RE-eo7" firstAttribute="top" secondItem="ajS-0W-q0R" secondAttribute="bottom" constant="4" id="R7I-5H-Njy"/>
-                            <constraint firstItem="3JG-RE-eo7" firstAttribute="leading" secondItem="ajS-0W-q0R" secondAttribute="leading" id="VUU-JW-C4P"/>
-                            <constraint firstItem="3JG-RE-eo7" firstAttribute="trailing" secondItem="GVf-Ac-B6w" secondAttribute="trailing" id="c7C-8z-H3G"/>
-                            <constraint firstAttribute="trailing" secondItem="GVf-Ac-B6w" secondAttribute="trailing" constant="12" id="ciC-sG-q15"/>
-                            <constraint firstItem="GVf-Ac-B6w" firstAttribute="centerY" secondItem="ajS-0W-q0R" secondAttribute="centerY" id="l00-xm-B3a"/>
-                            <constraint firstAttribute="trailing" secondItem="XA3-0v-ZPV" secondAttribute="trailing" id="uEw-Sz-hNY"/>
+                            <constraint firstItem="WSp-se-8ET" firstAttribute="leading" secondItem="11s-ic-gAj" secondAttribute="leading" id="4OF-qW-Tgk"/>
+                            <constraint firstItem="WSp-se-8ET" firstAttribute="top" secondItem="11s-ic-gAj" secondAttribute="bottom" constant="4" id="4u3-Kz-IXY"/>
+                            <constraint firstItem="2mQ-9u-Y6h" firstAttribute="leading" secondItem="iy0-4M-8sM" secondAttribute="leading" constant="16" id="AQl-dv-Zol"/>
+                            <constraint firstAttribute="bottom" secondItem="hJc-MH-D5J" secondAttribute="bottom" id="HAv-wm-4eH"/>
+                            <constraint firstItem="11s-ic-gAj" firstAttribute="leading" secondItem="2mQ-9u-Y6h" secondAttribute="trailing" constant="8" id="I2q-U9-oWS"/>
+                            <constraint firstAttribute="trailing" secondItem="hJc-MH-D5J" secondAttribute="trailing" id="IZO-hV-IhP"/>
+                            <constraint firstItem="2mQ-9u-Y6h" firstAttribute="centerY" secondItem="iy0-4M-8sM" secondAttribute="centerY" id="Vzm-Dh-y6B"/>
+                            <constraint firstItem="WSp-se-8ET" firstAttribute="trailing" secondItem="LLH-Q9-45f" secondAttribute="trailing" id="gC1-Xm-Rqw"/>
+                            <constraint firstItem="11s-ic-gAj" firstAttribute="top" secondItem="2mQ-9u-Y6h" secondAttribute="top" id="igb-9j-gDi"/>
+                            <constraint firstItem="LLH-Q9-45f" firstAttribute="centerY" secondItem="11s-ic-gAj" secondAttribute="centerY" id="klB-Ku-eOr"/>
+                            <constraint firstItem="hJc-MH-D5J" firstAttribute="leading" secondItem="WSp-se-8ET" secondAttribute="leading" id="mjs-hQ-Chq"/>
+                            <constraint firstAttribute="trailing" secondItem="LLH-Q9-45f" secondAttribute="trailing" constant="12" id="odj-1g-0wH"/>
                         </constraints>
                     </view>
                 </subviews>
-            </view>
-            <constraints>
-                <constraint firstAttribute="trailing" secondItem="uw9-ge-7Je" secondAttribute="trailing" id="3AT-CE-1xO"/>
-                <constraint firstItem="uw9-ge-7Je" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="SRo-Yj-MLL"/>
-                <constraint firstItem="uw9-ge-7Je" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Zsq-Uk-crn"/>
-                <constraint firstAttribute="bottom" secondItem="uw9-ge-7Je" secondAttribute="bottom" id="tAE-FU-lDp"/>
-            </constraints>
-            <size key="customSize" width="457" height="105"/>
+                <constraints>
+                    <constraint firstItem="iy0-4M-8sM" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="8dX-X6-3Js"/>
+                    <constraint firstAttribute="bottom" secondItem="iy0-4M-8sM" secondAttribute="bottom" id="TJ4-3N-y8C"/>
+                    <constraint firstAttribute="trailing" secondItem="iy0-4M-8sM" secondAttribute="trailing" id="fQb-1f-l4P"/>
+                    <constraint firstItem="iy0-4M-8sM" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="nPi-hF-wwP"/>
+                </constraints>
+            </tableViewCellContentView>
             <connections>
-                <outlet property="headImageView" destination="GOG-Kd-9jG" id="lVx-gt-2TJ"/>
-                <outlet property="msgLabel" destination="3JG-RE-eo7" id="e6M-Db-giO"/>
-                <outlet property="nameLabel" destination="ajS-0W-q0R" id="KCu-Ws-zAF"/>
-                <outlet property="timeLabel" destination="GVf-Ac-B6w" id="vOa-4J-G4V"/>
+                <outlet property="headImageView" destination="2mQ-9u-Y6h" id="mCg-u6-eCL"/>
+                <outlet property="msgLabel" destination="WSp-se-8ET" id="ytc-3V-rnR"/>
+                <outlet property="nameLabel" destination="11s-ic-gAj" id="zxV-dp-tik"/>
+                <outlet property="timeLabel" destination="LLH-Q9-45f" id="gnc-iN-8gM"/>
             </connections>
-            <point key="canvasLocation" x="119.23076923076923" y="18.127962085308056"/>
-        </collectionViewCell>
+            <point key="canvasLocation" x="70.992366412213741" y="24.295774647887324"/>
+        </tableViewCell>
     </objects>
     <resources>
         <image name="icon_ellipse" width="52.333332061767578" height="52.333332061767578"/>

+ 0 - 2
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/SLBaseMainView.h

@@ -18,8 +18,6 @@
 #import "SLVocabularyCell.h"
 #import "SLLxTopCell.h"
 #import "SLPlaceholderCell.h"
-#import "SLHomeMsgCollectionViewCell.h"
-
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 0 - 1
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/SLBaseMainView.m

@@ -44,7 +44,6 @@
     [self.mainCollectionView registerNibCellWithReuseIdentifierClass:SLLxTopCell.class];
     [self.mainCollectionView registerNibCellWithReuseIdentifierClass:SLVocabularyCell.class];
     [self.mainCollectionView registerNibCellWithReuseIdentifierClass:SLPlaceholderCell.class];
-    [self.mainCollectionView registerNibCellWithReuseIdentifierClass:SLHomeMsgCollectionViewCell.class];
 
     
     [self.mainCollectionView registerClass:UICollectionReusableView.class forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass(UICollectionReusableView.class)];

+ 4 - 1
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/SLHomeView.h

@@ -10,10 +10,13 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface SLHomeView : SLBaseMainView
+@interface SLHomeView : UIView
 
 @property (nonatomic, strong) SLCustNavView *navView;
 
+@property (nonatomic, strong) UITableView *tableView;
+
+@property (nonatomic, strong) NSMutableArray<SLChatListModel *> *viewModels;
 @end
 
 NS_ASSUME_NONNULL_END

+ 82 - 19
SLAiELTS/SLAiELTS/ViewControllers/Home/Views/SLHomeView.m

@@ -7,6 +7,11 @@
 
 #import "SLHomeView.h"
 #import "SLMessageViewController.h"
+#import "SLHomeMsgTableViewCell.h"
+
+@interface SLHomeView()<UITableViewDelegate, UITableViewDataSource>
+
+@end
 
 @implementation SLHomeView
 
@@ -21,11 +26,12 @@
 
 - (void)confignMyView
 {
+    [self.tableView registerNibCellWithReuseIdentifierClass:SLHomeMsgTableViewCell.class];
     [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.top.equalTo(self);
         make.height.equalTo(@(kNavBarHeight));
     }];
-    [self.mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
+    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.bottom.equalTo(self);
         make.top.equalTo(self.navView.mas_bottom).offset(1);
     }];
@@ -43,35 +49,74 @@
     [super layoutSubviews];
 }
 
-#pragma mark - UICollectionViewDataSource
-- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
-    SLPageViewModel *viewModel = [self.viewModels objectAtIndex:indexPath.section];
-    Class cellClass = viewModel.cellClass;
-    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(cellClass) forIndexPath:indexPath];
-    
-    cell.contentView.backgroundColor = self.contentBgColor;
-
-    //通用配置方法,cell各自实现相应的方法
-    [cell confignCellWithModel:viewModel.pageModel];
-//    [cell confignCellWithModel:viewModel.pageModel];
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return 74 * KScaleW;
+}
 
-    cell.contentView.clipsToBounds = YES;
+- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
+    SLHomeMsgTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SLHomeMsgTableViewCell"];
+    SLChatListModel *chatModel = [self.viewModels objectAtIndex:indexPath.row];
+    [cell confignCellWithModel:chatModel];
     return cell;
 }
 
+- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return self.viewModels.count;
+}
 
-- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
-{
-    SLPageViewModel *viewModel = [self.viewModels objectAtIndex:indexPath.section];
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
+    return YES;
+}
+
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
+    if (UITableViewCellEditingStyleDelete == editingStyle)
+    {
+        SLChatListModel *chatModel = [self.viewModels objectAtIndex:indexPath.row];
+        [[SLHttpCenter SharedInstance] getWithUrl:@"/api/Chat/DelChatRecord" parameter:@{@"friendId" : chatModel.friendId} success:^(id responseObject) {
+            [self delChatDataWith:chatModel];
+            [self.viewModels removeObjectAtIndex:indexPath.row];
+            [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
+        } failure:^(SPRequestError *error) {
+            
+        }];
+    }
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    SLChatListModel *chatModel = [self.viewModels objectAtIndex:indexPath.row];
     SLMessageViewController *vc = [SLMessageViewController loadViewControllewWithNib];
     SLFriendsModel *model = [[SLFriendsModel alloc] init];
-    model.contactsId = viewModel.pageModel.chatListModel.friendId;
-    model.userName = viewModel.pageModel.chatListModel.dataName;
-    model.userHead = viewModel.pageModel.chatListModel.dataHead;
+    model.contactsId = chatModel.friendId;
+    model.userName = chatModel.dataName;
+    model.userHead = chatModel.dataHead;
     vc.friendModel = model;
     [self.viewController navPushViewController:vc animated:YES];
 }
 
+- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
+    return 0.001f;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
+    return 0.001f;
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
+    UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
+    return view;
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
+    UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
+    return view;
+}
+
+- (void)delChatDataWith:(SLChatListModel *)chatModel {
+    NSString *key = [NSString stringWithFormat:@"%@--to--%@",[SLGlobalInfo SharedInstance].loginInfo.user.userId, chatModel.friendId];
+    [[NSUserDefaults standardUserDefaults] setObject:nil forKey:key];
+    [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
 - (SLCustNavView *)navView {
     if (!_navView) {
         _navView = [[SLCustNavView alloc] initWithFrame:CGRectZero];
@@ -81,4 +126,22 @@
     return _navView;
 }
 
+- (UITableView *)tableView {
+    if (!_tableView) {
+        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
+        _tableView.delegate = self;
+        _tableView.dataSource = self;
+        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+        [self addSubview:_tableView];
+    }
+    return _tableView;
+}
+
+- (NSMutableArray<SLChatListModel *> *)viewModels {
+    if (!_viewModels) {
+        _viewModels = [NSMutableArray array];
+    }
+    return _viewModels;
+}
+
 @end